Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I detect if Python is running in Python Development Mode?

To turn on Python Development Mode, you can use this flag:

python3 -X dev example.py

or use this environment variable:

PYTHONDEVMODE=1 python3 example.py

How can I write code within example.py to detect whether Python is running in Python Development Mode or not?

like image 609
Flimm Avatar asked Dec 05 '25 18:12

Flimm


1 Answers

sys.flags.dev_mode is True, when running as python -X dev app.py

like image 104
Sameera K Avatar answered Dec 08 '25 08:12

Sameera K



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!