Exception handling

Alex Martelli aleax at aleax.it
Wed May 8 06:54:48 EDT 2002


Järvinen Petri wrote:

> Hello
> 
> Is it possible to use dynamic binding in exception handling like in C++.
> 
> I mean can I catch baseclass exception in my exception handler and get all
> the derived classes catched aswell, like
> 
> Class A:
> 
> Class B(A):
> 
> Class C(A):
> 
> try:
>  ...
> except A:
>  (this would catch also B and C)

Yes, this IS how exception handling is defined to work in Python.


Alex




More information about the Python-list mailing list