Type Identification
Fredrik Lundh
effbot at telia.com
Wed Feb 9 15:10:41 EST 2000
Jonathan Donald wrote:
> I'm brand new to Python, and I'm having difficulty testing for
> the class of an object.
/.../
> ...why does the following expression not return false?
> if type(fNode) == type(aDirectoryRecord):
print type(fNode) and type(aDirectoryRecord),
and you'll discover that they're both "instance"
objects.
the function you're looking for is called "isinstance":
http://www.python.org/doc/current/lib/built-in-funcs.html#l2h-124
also see:
http://www.python.org/doc/FAQ.html#4.47
</F>
<!-- (the eff-bot guide to) the standard python library:
http://www.pythonware.com/people/fredrik/librarybook.htm
-->
More information about the Python-list
mailing list