__debug__ http://stackoverflow.com/questions/15305688/conditional-debug-statement-not-executed-though-debug-is-true
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Wed Nov 16 03:39:38 EST 2016
On Wednesday 16 November 2016 16:21, Veek M wrote:
> Trying to make sense of that article. My understanding of debug was
> simple:
> 1. __debug__ is always True, unless -O or -OO
> 2. 'if' is optimized out when True and the expr is inlined.
>
> So what does he mean by:
>
> 1. 'If you rebind __debug__, it can cause symptoms'
What he means is, "I didn't test this code before running it, and I am wrong."
You cannot rebind __debug__.
>>> __debug__ = False
File "<stdin>", line 1
SyntaxError: can not assign to __debug__
(That's Python 2.5 or better, and maybe even older than that.)
--
Steven
299792.458 km/s — not just a good idea, it’s the law!
More information about the Python-list
mailing list