wurmy at earthlink.net
Tue Aug 20 18:45:11 CEST 2002
Chris Lyon wrote:
> How do I find out what type of object an instance is?
> I can use isinstance but I have to know the class I am expecting, and
> if this involves sub-classes then I have long winded successions of
> isinstance where the order is very important because sub-classes are
> instances of their super class.
I think you want the __class__ attribute:
>>> class Foo: pass
>>> foo = Foo()
<class __main__.Foo at 0x0090D808>
Or maybe, for your sorting purposes:
# decode for email address ;-)
The Pythonic Quarter:: http://www.awaretek.com/nowak/
More information about the Python-list