type() new style class instance says "class", not "ObjectType"
Brad Clements
bkc at Murkworks.com
Wed Apr 10 18:38:47 EDT 2002
Could someone explain this to me.
Lots of code does type(x) in [InstanceType]
One might imagine that to support new style classes, this would be changed
to:
type(x) in [InstanceType,ObjectType]
But that doesn't work because type(new style instance) returns "Class"
>>> class x(object):
... pass
...
>>> y = x()
>>> type(y)
<class '__main__.x'>
>>> type(x)
<type 'type'>
This seems the best way:
>>> isinstance(y,ObjectType)
1
>>>
I'm hoping someone can illucidate this for me.
--
Novell DeveloperNet Sysop #5
_
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
Check out our new Unlimited Server. No Download or Time Limits!
-----== Over 80,000 Newsgroups - 19 Different Servers! ==-----
More information about the Python-list
mailing list