__debug__

The built-in variable __debug__ is True under normal circumstances, False when optimization is requested (command line option -O).

Assignments to __debug__ are illegal. The value for the built-in variable is determined when the interpreter starts.