Built-in Exceptions
IsADirectoryError — exception class
A file operation was attempted on a directory. Choose the correct filesystem API for the path type rather than treating a directory as a regular file. The example uses the symbolic errno.EISDIR 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 IsADirectoryError when this category is the recovery boundary; do not rely on the exact human-readable message.
Formal Syntax & Structure
python syntaxpython
IsADirectoryErrorReturn Value
type
The class object IsADirectoryError; this reference documents the class identity, not a universal constructor signature.
Working Example
Example Snippetpython
import errnotry: raise OSError(errno.EISDIR,"demo")except IsADirectoryError as error: print(type(error).__name__)