Question

I am using Visual Studio 12 with Python Tools for Visual Studio 1.5 to develop Python programs. That works very well.

Now I would like to check within the Python code whether we are running within Visual Studio or not. Is there an easy way to achieve this?

Was it helpful?

Solution

import sys
if '$visualstudio_py_debugger' in sys.modules:
    print("Running in Visual Studio")
else:
    print("Running outside Visual Studio")
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top