Type Problem
Michiel Overtoom
motoom at xs4all.nl
Tue Jul 15 10:06:48 EDT 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:
directorycount=len(dirs)
Greetings,
>>> type(len)
<type 'builtin_function_or_method'>
>>> print len("Victor")
6
>>> len=42
>>> type(len)
<type 'int'>
>>> len("Victor")
Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
len("Victor")
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
http://www.catb.org/~esr/halloween/halloween4.html
More information about the Python-list
mailing list