debug_print.py
def debug_print(s):
if not __debug__:
print(s)
Wenn du es so machst,
test.output
$ python -c '(__import__)("debug_print").debug_print(__debug__)'
$ python -O -c '(__import__)("debug_print").debug_print(__debug__)'
False
Es wird nur gedruckt, wenn die Option "-O" hinzugefügt wird.
Recommended Posts