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

Tom Kermode tkermode at
Thu Jul 9 12:06:45 EDT 2009


   Do you know a good way to avoid running into this problem?  It
makes sense to suggest not calling variables the same names as
built-in functions, but that's hard for a new python programmer who
doesn't already know what all the built-in functions are. Over time a
programmer will learn which names to avoid, but it's a bit of a
pitfall early on.


2009/7/9 Richard Brodie <R.Brodie at>:
> "Nick" <nleioatt at> wrote in message
> news:e54c4461-c0b7-42fb-8542-cefd7bf5f89f at
>> 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