[Tutor] i have got problems handling the types module

Remco Gerlich scarblac@pino.selwerd.nl
Thu, 29 Mar 2001 21:19:45 +0200


On Thu, Mar 29, 2001 at 08:27:16PM +0200, Marcus Konermann wrote:
> Hello !
> 
> i want to use the types module for different comparisons like the
> following:
> 
> import types
> c=3.5
> if type(c) == types.FloatType:
> print 'Itīs a float !'
> 
> the error output is the following:
> TypeError: call of non-function (type string)
> and i donīt know why.
> So, i need a solution to this problem.

You probably have a variable named 'type', containing a string. That
overrides the builtin function called type. So now 'type(c)' is trying to do
a function call on a string.

Beware of giving variables names like 'type', 'str', et cetera.

-- 
Remco Gerlich