Is types.InstanceType no longer valid with Python 2.2
Jason Orendorff
jason at jorendorff.com
Fri Jan 4 12:01:23 EST 2002
> You see the problem?! With old-type classes the comparision succeeds,
> with new-type classes it fails.
> The type of the instance will show the whole class-structure, but
> that's not of any interest (as mentioned in posting to Emile).
> Okay, one way would be to compare the type of the object with all
> other types in 'types' (except InstanceType). If all fail, the object
> must be an instance of a class. Not very satisfying, is it.
isinstance(x, object) # true for all new-style instances
issubclass(type(x), object) # ditto
## Jason Orendorff http://www.jorendorff.com/
More information about the Python-list
mailing list