Type Problem

Michiel Overtoom motoom at xs4all.nl
Tue Jul 15 16:06:48 CEST 2008

Victor wrote...

>len = len(dirs)

The function 'len' is a built-in function in Python. If you assign an
integer to the name 'len', that will replace the function with an int. And
you can't call an int.

My suggestion: Do not use 'len' as a variable name. Use something else, like:



>>> type(len)
<type 'builtin_function_or_method'>

>>> print len("Victor")

>>> len=42

>>> type(len)
<type 'int'>

>>> len("Victor")
Traceback (most recent call last):
  File "<pyshell#4>", line 1, in <module>
TypeError: 'int' object is not callable

"The ability of the OSS process to collect and harness
the collective IQ of thousands of individuals across
the Internet is simply amazing." - Vinod Vallopillil

More information about the Python-list mailing list