What is the actual type of "interrupted system call"?

Jean-Michel Pichavant jeanmichel at sequans.com
Wed Jun 10 05:05:46 EDT 2009


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





More information about the Python-list mailing list