[Tutor] Problems with changing directory.

Danny Yoo dyoo at hkn.eecs.berkeley.edu
Mon Aug 23 03:49:02 CEST 2004



On Sun, 22 Aug 2004, Kent Johnson wrote:

> Until you get this working it might be better to omit the try block
> completely. Then an exception will give you a stack trace and a precise
> error message. If you don't understand the error message, post it here
> and we will help. Once you have it working you can add in try blocks
> that catch specific, expected errors and handle them in a user-friendly
> way.

Yes; change the except clause.  Either drop the exception handling, so
that the system can tell specifically why it's having problems, or adjust
the exception handler so it's more informative.


A quick way to make an exception more informative is to use the
'traceback.print_exc()' function:

    http://www.python.org/doc/lib/module-traceback.html

Something like:

###
     except:
         print y, "does not exist"
         traceback.print_exc()
###


will make the debugging easier.  (Doesn't this seem related to our thread
about exceptions just a week ago?  *grin*)



More information about the Tutor mailing list