[Python-Dev] if __debug__: except Exception, e: pdb.set_trace()

Calvin Spealman ironfroggy at gmail.com
Mon Oct 9 09:24:28 CEST 2006

I know I can not do this, but what are the chances on changing the
rules so that we can? Basically, since the if __debug__: lines are
processed before runtime, would it be possible to allow them to be
used to control the inclusion or omission or entire blocks (except,
else, elif, etc.) with them being included as if they were at the same
level as the 'if __debug__:' above them?

I want to allow this:

if __debug__:
    except Exception, e:
        import pdb

So that when __debug__ is false, the except block doesn't even exist at all.
Read my blog! I depend on your acceptance of my opinion! I am interesting!

More information about the Python-Dev mailing list