Finding a Specific Class's Instance in a List

Fernando Pérez fperez528 at yahoo.com
Mon Nov 26 22:44:06 CET 2001


A. Keyton Weissinger wrote:

>     print "My List:", myList
>     i=0
>     for obj in myList:
> ------- if obj.__class__ == Class2:
          
  +++++++ if isinstance(obj,Class2):

>             print "Found it at", i
>         i += 1

I think that's what you want.

f



More information about the Python-list mailing list