[Tutor] question about try & except

Alan Gauld alan.gauld at freenet.co.uk
Thu Oct 27 10:06:27 CEST 2005

> and i am using some try / except statements. 
> the problem is, that even though my script does not crash, i dont know
> the exact error. 

IT sounds like your try/except is masking the error.
Its usually a good idea to NOT Use try/except when developing your 
code, then go back and put it in when the basics are working. That way 
Pythons own exception handling will catch the error, force a break and 
print the stacktrace whoich helps identify the problem.

> is there a parameter that will allow me to use try and except but that
> will also pring out the traceback statements that python usually does to
> the terminal?

One technique is to simply call raise within each exception block, 
then comment out the raise lines when you no longer need them.


Alan G
Author of the learn to program web tutor

More information about the Tutor mailing list