Expansion of the __debug__ and pass concepts
Alex Martelli
aleaxit at yahoo.com
Wed Nov 1 12:32:51 EST 2000
"Alex" <not_such_a_brain_after_all at mit.edu> wrote in message
news:etdy9z4wnx3.fsf at oliver.mit.edu...
>
> You're going to have to rototill your code to do things this way, but
> you may be able to automate most of the job, and it doesn't require
> changes to the interpreter:
>
> If you compile with -O, I believe __debug__ gets automatically set to 0,
> and blocks like:
>
> if __debug__:
> DBG(DBG.DM_DEFAULT, "The value for x is : %d", x)
>
> get optimized away during compilation.
Yes! And as long as your DBG function returns any true value,
you may also choose to express this as
assert DBG(etc)
This is not substantially more compact than
if __debug__: DBG(etc)
but is roughly equivalent.
Alex
More information about the Python-list
mailing list