How to disable assert statements inside a module?

Martin v. Loewis martin at v.loewis.de
Mon Mar 11 00:29:10 EST 2002


Tim Peters <tim.one at comcast.net> writes:

> Note that assignment to __debug__ was deprecated in 2.1:
> 
>     SyntaxWarning: can not assign to __debug__
> 
> and removed in 2.2:
> 
>     SyntaxError: can not assign to __debug__

Of course,

def foo(x):
     assert x

globals()['__debug__'] = 0
foo(0)

continues to work.

Regards,
Martin



More information about the Python-list mailing list