Is types.InstanceType no longer valid with Python 2.2
Martin v. Loewis
martin at v.loewis.de
Sat Jan 5 02:37:12 EST 2002
Skip Montanaro <skip at pobox.com> writes:
> How can foo be a classic class with no bases, f1 be both an instance of foo
> and of object, but foo not be a subclass of object?
Would you agree that the following is sensible:
>>> class foo:pass
...
>>> f=foo()
>>> import types
>>> isinstance(f,types.InstanceType)
1
f's type is <type 'instance'>, so f is an instance of InstanceType,
just as isinstance(1, int). Now, would you also agree that
>>> types.InstanceType.__bases__
(<type 'object'>,)
is meaningful, i.e. that object is a base of instance? (every type,
eventually, has object as a base type)
If you accept both separately, you should also accept
isinstance(f, object).
Regards,
Martin
More information about the Python-list
mailing list