Python Glossary Русский

Python 3.3+faulthandlerfunction

faulthandler.is_enabled()

fault handler state

Returns True if the fault handler is on — via enable(), the -X faulthandler option or the environment variable.

Syntax

faulthandler.is_enabled()

False by default, but not always: python -X dev and PYTHONFAULTHANDLER=1 turn the handler on before the first line of your program, so the same check can answer differently in an IDE and a terminal. Before your own enable() with a file, save the previous state so you do not switch off someone else's setting.

Examples

import faulthandler, sys
print(faulthandler.is_enabled())  # → False — без -X dev и PYTHONFAULTHANDLER
faulthandler.enable(file=sys.stdout)
print(faulthandler.is_enabled())  # → True
faulthandler.disable()

See also

Open in the full glossarydocs.python.orgReport an inaccuracy