Exception Attributes
OSError.errno — exception attribute
Use the numeric operating-system error code to classify a failure. Compare against symbolic errno constants rather than hard-coded numbers or localized messages. A manually constructed OSError without a numeric code can have None.
Formal Syntax & Structure
python syntaxpython
error.errnoReturn Value
int | None
Portable-style error number when supplied.
Working Example
Example Snippetpython
import errnoerror = OSError(errno.ENOENT, "missing input", "input.txt", None, "output.txt")print(error.errno == errno.ENOENT)