Built-in Exceptions

EOFError — exception class

Signals end of input before input() can read a line. This differs from reading an empty line, which yields an empty string, and from file.read(), which normally returns an empty sequence at EOF. Catch EOFError when this category is the recovery boundary; do not rely on the exact human-readable message.

Formal Syntax & Structure

python syntaxpython
EOFError

Return Value

type

The class object EOFError; this reference documents the class identity, not a universal constructor signature.

Working Example

Example Snippetpython
import iofrom unittest.mock import patchtry:    with patch("sys.stdin", io.StringIO("")):        input()except EOFError as error:    print(type(error).__name__)
Python Reference