Debugging a script

Gabriel Genellina gagenellina at softlab.com.ar
Fri Jan 2 20:40:53 EST 2004


At 2/1/2004 20:23, you wrote:

>I've got a (python) program which crashes.  WHat I'd like to do is something
>loke this:
>
>         try:
>                 lots of stuff, or
>                 more pertinintly, the code which is failing
>         except:
>                 drop in to the debugger
>
>So that I can print various things.
>
>Also, is there a way to display the line number  - eg:
>         except something:
>                 print ("DEBUG: exception %s at line number %s" % 
> (sys.exc_type,
>sys.linenumber))

Better to print a full traceback instead of just one line number. Look at 
the traceback module:

         except:
                 import traceback
                 traceback.print_exc()



Gabriel Genellina
Softlab SRL





More information about the Python-list mailing list