Is types.InstanceType no longer valid with Python 2.2

Martin v. Loewis martin at
Sat Jan 5 02:37:12 EST 2002

Skip Montanaro <skip at> 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)

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).


More information about the Python-list mailing list