gett error message: "TypeError: 'int' object is not callable"
Bruno Desthuilliers
bruno.42.desthuilliers at websiteburo.invalid
Thu Jul 9 10:24:19 EDT 2009
Nick a écrit :
> I've seen a lot of posts on this problem, but none seems to help.
> Here is the code:
> /code
>
> file = open(prefix1)
shadows the builtin 'file' type.
> text = file.readlines()
> len = len(text)
shadows the builtin 'len' function.
> fields = text[1].split()
> num_rows = int(fields[1])
> num_cols = int(fields[2])
>
> U1_matrix = []
>
> print fields
> print repr(fields)
> print len(fields)
And here's your problem - 'len' is now bound to the result of the
previous call to len(text).
Hint : Python's functions, classes and modules are objects too, and
don't live in a distinct namespace. So _don't_ use builtin's types /
functions / etc names as identifiers.
HTH
More information about the Python-list
mailing list