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
--
http://mail.python.org/mailman/listinfo/python-list