Search code examples
pythonpdb

Is there a function to see if the python file is run using "-m pdb"?


When I use "-m pdb", some code is not working properly. So I want to know if there is a way to see if the file is run using "-m pdb" to choose different method to run my code.


Solution

  • You can test with :

    "pdb" in sys.modules