0

I'm trying to figure out how to determine in code whether I'm in debug mode or not. Basically I've got 2 different configurations that I want to run based on whether I'm in debug mode or not. Basically like this...

if DEBUG:
    a = 1
else:
    a = 2

Is it something in Run > Edit Configurations? I can't quite figure it out.

1 Answer 1

3

You can detect PyCharm debugger this way:

import sys
if 'pydevd' in sys.modules:
    pass # debugger detected

Another option (which looks better from my point of view) is to make dfiferent run parameters with different enviroments.

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.