gett error message: "TypeError: 'int' object is not callable"

Richard Brodie R.Brodie at rl.ac.uk
Thu Jul 9 10:02:27 EDT 2009


"Nick" <nleioatt at gmail.com> wrote in message 
news:e54c4461-c0b7-42fb-8542-cefd7bf5f89f at h18g2000yqj.googlegroups.com...

> file = open(prefix1)
> text = file.readlines()
> len = len(text)

You have redefined two built-in functions "file" and "len" in the first three lines.
This is usually considered poor practice. Stick to meaningless variable names,
it's safer (only joking).

TypeError: 'int' object is not callable". This means that something you thought
was a function is in fact an integer. It's helpful to post/look at the line number of
the error; "how is this line failing", is much easier to answer than
"how is my program failing".

print len(fields)

Here len is an integer, because you redefined it in line 3. I'm guessing this is the
problem. 





More information about the Python-list mailing list