[Python-Dev] Assigning to __debug__

Barry A. Warsaw barry@digicool.com
Fri, 30 Mar 2001 10:38:48 -0500


>>>>> "GvR" == Guido van Rossum <guido@digicool.com> writes:

    GvR> The *only* acceptable use for __debug__ is to get rid of code
    GvR> that is essentially an assertion but can't be spelled with
    GvR> just an assertion, e.g.

Interestingly enough, last night Jim Fulton and I talked about a
situation where you might want asserts to survive running under -O,
because you want to take advantage of other optimizations, but you
still want to assert certain invariants in your code.

Of course, you can do this now by just not using the assert
statement.  So that's what we're doing, and for giggles we're multiply
inheriting the exception we raise from AssertionError and our own
exception.  What I think we'd prefer is a separate switch to control
optimization and the disabling of assert.

-Barry