So you are suggesting that we change all our code to something like:
__enable_debug__ = 0 # set to 0 for production mode
...
if __debug__ and __enable_debug__: print 'debugging information'
...
I can't suggest anything, because I have no idea what semantics you are assuming for __debug__ here, and I have no idea what you want with that code. Maybe you'll want to say "__debug__ = 1" even when you are in -O mode -- that will definitely not work! The form above won't (currently) be optimized out -- only "if __debug__:" is optimized away, nothing more complicated (not even "if (__debug__):". In any case, YOU SHOULD NEVER INTRODUCE VARIABLES USING THE __UNDERSCORE__ CONVENTION! Those names are reserved for the interpreter, and you risk that they will be assigned a different semantics in the future.
I don't see the point in having to introduce a new variable just to disable debugging code in Python code which does not run under -O.
What does defining __debug__ as read-only variable buy us in the long term ?
It allows the compiler to assume that __debug__ is a built-in name. In the future, the __debug__ variable may become meaningless, as we develop more differentiated optimization options. The *only* acceptable use for __debug__ is to get rid of code that is essentially an assertion but can't be spelled with just an assertion, e.g. def f(L): if __debug__: # Assert L is a list of integers: for item in L: assert isinstance(item, type(1)) ... --Guido van Rossum (home page: http://www.python.org/~guido/)