Menu ▾ ▴

Detecting in debug mode

Lin Parkh
2008-11-12
2013-03-15
  • Lin Parkh

    Lin Parkh - 2008-11-12

    Hi,
    I would like my code when executing to know that I am running in debug mode. __debug__ only distinguishes running for optomization or not. Is there another globally visible variable I could use?
    Thanks,
       Lin

     
    • Fabio Zadrozny

      Fabio Zadrozny - 2008-11-16

      There's no real global variable to identify that... but a way to detect it would be:

      def IsInDebugMode():
      ....try:
      ........import pydevd_comm
      ....except ImportError:
      ........return False
      ....else:
      ........return pydevd_comm.GetGlobalDebugger() is not None

      Cheers,

      Fabio