If I'm in debug mode, I want to do other stuff than when I'm not.
if DEBUG:
STORED_DATA_FILE = os.path.join(TEMP_DIR, 'store.dat')
LOG_LEVEL = logging.DEBUG
print "debug mode"
else:
STORED_DATA_FILE = os.path.join(SCRIPT_PATH, 'store.dat')
LOG_LEVEL = logging.INFO
print "not debug mode"
then:
python script.py
not debug mode
python -d script.py
debug mode
How can I detect that? It certainly isn't using the __debug__
variable.
you can use python -O
with the __debug__
variable
where -O
means optimise. so __debug__
is false
-d
turns on debugging for the parser, which is not what you want
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With