Python Forum
How in Eclipse recognize debug / run mode? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: General (https://python-forum.io/forum-1.html)
+--- Forum: News and Discussions (https://python-forum.io/forum-31.html)
+--- Thread: How in Eclipse recognize debug / run mode? (/thread-16940.html)



How in Eclipse recognize debug / run mode? - AlekseyPython - Mar-21-2019

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?


RE: How in Eclipse recognize debug / run mode? - nilamo - Mar-21-2019

https://docs.python.org/3/library/constants.html#__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