3

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?

6
  • Does this answer your question? Check if my application runs in development/editable mode Commented Oct 23, 2020 at 14:01
  • the doc speak about the variable __debug__ Commented Oct 23, 2020 at 14:06
  • 2
    if you use the environment var method you could check os.environ Commented Oct 23, 2020 at 14:09
  • 1
    @SimonHostettler No, that doesn't answer my question, as that question talks about editable mode, not Python Development Mode. Commented Oct 23, 2020 at 14:23
  • 1
    @rioV8 The variable __debug__ is True even when Python Development Mode is not on. I just tried it by running python3 and then running python3 -X dev Commented Oct 23, 2020 at 14:24

1 Answer 1

3

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.