Python Forum

Full Version: How in Eclipse recognize debug / run mode?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Python 3.7.2, Eclipse 12/2018

In order for the interface to work in the program, I create a new process and start the heavy procedure in it. But when I debugging program it is not suitable and in this case I do everything in the Python process. Therefore, in the code I need to find out, in which mode the application was launched. I tried to use the construct:
if __debug__:
    print 'Debug ON'
else:
    print 'Debug OFF'
, but it always comes into the debug branch.

How can I recognize debug or run mode?
https://docs.python.org/3/library/consta...#__debug__ Wrote:This constant is true if Python was not started with an -O option. See also the assert statement.

Can you change how Eclipse runs your script, so you can run it with the -O flag?
C:\Users\xyz>python -c "print(__debug__)"
True

C:\Users\xyz>python -O -c "print(__debug__)"
False