mrstevegross wrote:
exceptions.EOFError exceptions.ReferenceError exceptions.ZeroDivisionError
...
exceptions.NotImplementedError exceptions.UnicodeError exceptions.__str__

Is there a single parent exception to all those? Or should I just
write it as:

try:
 ...
catch Exception:
 ...

Thanks,
--Steve
You're right, Exception is the parent of (almost) all exceptions.
I wouldn't advise writing such block catching all exceptions, it makes error tracking quite difficult. However if you don't know the type of exception involved in a particular case, you can write

try:
...
except Exception, excInstance:
print excInstance.__class__.__name__
print excInstance.__dict__

If you know how to trigger the exception, it should print the class name of the exception, along with its attributes. It will help you then write a more focused except clause.

Jean-Michel


--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to