dropping into the debugger on an exception

Peter Hansen peter at engcorp.com
Wed Jun 9 19:59:05 CEST 2004

Jon Perez wrote:

> Thomas Heller wrote:
>>> Just to be clear: you don't want this to happen all the time,
>>> you want it to happen only with a particular script, yet you
>>> don't want to modify that script at all?
>> I also don't understand *why* he wants to have it that way.
> Just in case you missed the answer I gave earlier...
> I don't even want this behaviour all the time with the same
> script because end-users will be confused if they get dropped
> into pdb.  Believe me, you don't want to explain what pdb is
> to people who have a hard time even navigating via the
> command prompt!
> The best situation would be to be able to invoke this behaviour
> only when I want it (i.e. during coding/debugging) 

Basically this seems to require command line options, right?j
If so, just include a standard snippet in the __main__ section
of your scripts which checks the first command line option to
see if it's "--jon's_special_pdb_magic" (or whatever ;-) ) and
then programmatically invoke the excepthook stuff...


More information about the Python-list mailing list