type() for new style classes - buggy?
Michal Vitecek
fuf at mageo.cz
Wed Jan 28 08:02:04 EST 2004
hello,
does the type() command work correctly for new style classes? i guess
it does not, unfortunately. for example, for a new style class'
instance it returns <class '__main__.ClassName'>, but for old style
class' instance it returns <type 'instance'>.
>>> import types
>>> class A(object):
pass
>>> class B:
pass
>>> type(A())
<class '__main__.A'>
>>> type(B())
<type 'instance'>
>>> type(A()) == types.InstanceType
0
>>> type(B()) == types.InstanceType
1
how can one then determine what he's working with when he uses new
style classes (either instance or class)?
thank you,
--
fuf (fuf at mageo.cz)
More information about the Python-list
mailing list