Chapters
Python114 chapters

ReferenceException types

OSError

The parent of the filesystem and operating-system errors.

Signature

OSError(message)

Returns

Catching it also catches its subclasses.

Example

Python
try:
    open("missing.txt")
except OSError as problem:
    print("caught as OSError:", type(problem).__name__)

Output

caught as OSError: FileNotFoundError

See also