Comparing variable types

KefX keflimarcusx at aol.comNOSPAM
Sat Oct 25 22:44:46 EDT 2003


>type(i) == "<type 'float'>"
>this always returns false.  How come?
>type(i)returns <type 'float'> if i is a float so why isn't == working?

Use isinstance(), like this:
isinstance(i, float)
This will return True if i is a float, False if not.

- Kef




More information about the Python-list mailing list