Python Forum
How in Eclipse recognize debug / run mode?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How in Eclipse recognize debug / run mode?
#1
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?
Reply
#2
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  this message show up for me. cant debug notinhg here davidthomas 0 651 Jun-29-2023, 05:44 PM
Last Post: davidthomas
  Improved Python support in SonarLint (PyCharm! Eclipse!) ganncamp 0 2,478 Apr-29-2020, 06:25 PM
Last Post: ganncamp
  steps to debug regular expressions Skaperen 3 1,853 Oct-22-2019, 10:04 PM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020