False
if you add -O
when executing python, otherwise it becomes True
. (This is a capital letter O, not zero)debug_print.py
def debug_print(s):
if not __debug__:
print(s)
If you make it like this,
test.output
$ python -c '(__import__)("debug_print").debug_print(__debug__)'
$ python -O -c '(__import__)("debug_print").debug_print(__debug__)'
False
Like, it is printed only when the -O
option is added.
Recommended Posts