Single test for a class and all its subclasses?

Konstantin Veretennicov kveretennicov at gmail.com
Wed Jun 15 05:28:58 EDT 2005


On 6/15/05, Anthra Norell <anthra.norell at tiscalinet.ch> wrote:
>  
> class C: ... 
> class C2 (C): ... 
>  
> # What I want to do: 
>  
> if x.__class__ in (C, C2): 
>    do_something_with (x) 

If you have an instance, you can use isinstance() built-in.

- kv



More information about the Python-list mailing list