Equivalent to c++ typeof(x)
Michael Chermside
mcherm at destiny.com
Wed Jan 9 11:48:53 EST 2002
> Is there any equivalent in Python to the C++ construct
>
> typeof(<instance variable>) == typeof(<class>)
You might try this:
a.__class__ == b.__class__
But there's probably a better way involving isinstance().
Of course, this causes problems if one of the objects is replaced by a
subtype of the expected type, but that's inherent in the posed problem
of making sure that two objects have the same type.
-- Michael Chermside
More information about the Python-list
mailing list