detecting debug mode for python in visual studio

Let’s say I have a file called script.py which I am running under Visual Studio 2022 Community Edition. I am running script.py by right clicking on the window and choosing `Start with debugging’ or ‘Start without debugging’. I would like to detect which mode it is launched in from inside the script. For C++, the preprocessor macro _DEBUG is defined in debug mode, and I can use something like

#ifdef _DEBUG
debugging code
#endif

I would like to know how to do something similar for python.

Read more here: Source link