alan.gauld at btinternet.com
Mon Aug 27 14:00:44 CEST 2007
"Kent Johnson" <kent37 at tds.net> wrote
>> if type(x) == type(int()):
> For the built-in types, since Python 2.2 the familiar name (int,
> float, list, dict, set) *is* the type and you can compare to that
> directly, e.g.:
> In : type(3)==int
> Out: True
I knew I should be able to use int but I tried to be too clever
and used type(int) which of course returns 'type type'. So I
used the default int() constructor which returns zero...
For some reason I never thought of simply comparing type()
to int... doh!
More information about the Tutor