Class types

Jame.Thu jame at mails.tsinghua.edu.cn
Tue Aug 20 18:52:41 CEST 2002


>>> class myclass:
...  pass
...
>>> o = myclass()
>>> print o.__class__
__main__.myclass
>>>

is that what you need?

"Chris Lyon" <chris.lyon at tgm.co.uk> wrote in message
news:7652d5e7.0208200713.7cd84020 at posting.google.com...
> 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 ask because I am trying to return a list of different objects which
> are all examples of sub classes of a particular class and I would like
> to order them by the sub class they are from. I've used isinstance and
> allocated a weighting which Is apprpriate but I feel I'm missing
> something.





More information about the Python-list mailing list