Reputation: 248
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
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