Cameron
Cameron

Reputation: 248

PyCharm debug mode with Python 3

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.

Upvotes: 0

Views: 278

Answers (1)

Daniil Ryzhkov
Daniil Ryzhkov

Reputation: 7596

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.

Upvotes: 3

Related Questions