Built-in Exceptions
FileNotFoundError — exception class
A requested path does not exist, including a missing parent directory. Check the path and intended working directory; avoid silently creating a replacement if missing data is an error. The example uses the symbolic errno.ENOENT to demonstrate CPython exception selection without accessing an external system. The example raises a controlled stand-in to demonstrate handling; it does not cause the real system failure. Catch FileNotFoundError when this category is the recovery boundary; do not rely on the exact human-readable message.
Formal Syntax & Structure
python syntaxpython
FileNotFoundErrorReturn Value
type
The class object FileNotFoundError; this reference documents the class identity, not a universal constructor signature.
Working Example
Example Snippetpython
import errnotry: raise OSError(errno.ENOENT,"demo")except FileNotFoundError as error: print(type(error).__name__)