Yes,

You can catch an error object along with the exception, as in:

try:
     fileo = open("nofile")
except IOError, e:
     print "Alas...", e

As you see, the error object has a string representation equal wo what 
normally the python interpreter prints...

 >>>
Alas... [Errno 2] No such file or directory: 'nofile'
 >>>


Hope it helps. It took me originally a long time to know this trick, as 
it's kinda buried in the docs.

Hugo


nephish wrote:
> Hey there,
>       i am writing some (for me) pretty complicated stuff for work that
> really needs to work. 
>       i have looked at exception handling in the Learning Python book.
> 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. 
>       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?
> 
>       thanks
> 
> _______________________________________________
> Tutor maillist  -  [email protected]
> http://mail.python.org/mailman/listinfo/tutor
> 
_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to