Comparing variable types
Peter Hansen
peter at engcorp.com
Sun Oct 26 08:32:11 EST 2003
Emile van Sebille wrote:
>
> "Kill Bill" <bill at kill.com> wrote in message
> news:bnfbuj$10f3di$1 at ID-198839.news.uni-berlin.de...
> > type(i) == "<type 'float'>"
>
> This compares the current type of i to type("string"), which is <type
> 'str'>.
(Minor correction) Actually it compares it to the actual string
containing the letters "<type 'float'>", which is of course going
to get one nowhere.
The above would have worked if the OP had used
repr(type(i)) == "<type 'float'>"
but that is the absolute worst way of doing this...
-Peter
More information about the Python-list
mailing list