How do I check if the python debug option is set from within a script

后端 未结 2 696
攒了一身酷
攒了一身酷 2021-01-04 19:15

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 = lo         


        
2条回答
  •  孤街浪徒
    2021-01-04 19:30

    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

提交回复
热议问题