This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author steven.daprano
Recipients eric.araujo, o11c, steven.daprano
Date 2012-07-06.01:58:41
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1341539923.28.0.170051232951.issue15248@psf.upfronthosting.co.za>
In-reply-to
Content
I think this suggested enhancement is unreasonable and of limited usefulness, and even if it were useful, too specialised to bother with.

The obvious message is badly misleading. When I read this:

TypeError: 'tuple' object is not callable, a comma may be missing

I look inside the tuple for a missing comma. But that's not the problem, and the error message sends me on a wild goose chase wondering how on earth a missing comma causes Python to try calling my tuple. I've been programming in Python for 15+ years and it mislead me -- what do you think it will do to beginners?

The problem is that the tuple is inside a list, and the LIST is missing a comma.

What about this example?

result = function(
    "the error has nothing to do with tuples"  # oops missed a comma
    (2, 3, 4),
    None
    )

Should the error message say something like:

TypeError: 'str' object is not callable, perhaps it is embedded in a list, tuple, 
function call or some other place you need a comma, and you forgot one 
or more commas?

I don't think so. Besides, most of the time when you get this TypeError, it will be because you genuinely tried to call what you thought was a function but wasn't, and the hint is pointless.

You tried to call a tuple as if it were a function. The reason for that is that you left out a comma in a list, but there are many other reasons that could happen, and "I frequently forget to add commas to lists" is a far too-specialised failure mode to single it out in the error message.

It is unreasonable to expect Python to debug your code for you. It tells you what you did wrong -- you called a tuple as a function -- and it is up to you to determine why.
History
Date User Action Args
2012-07-06 01:58:43steven.dapranosetrecipients: + steven.daprano, eric.araujo, o11c
2012-07-06 01:58:43steven.dapranosetmessageid: <1341539923.28.0.170051232951.issue15248@psf.upfronthosting.co.za>
2012-07-06 01:58:42steven.dapranolinkissue15248 messages
2012-07-06 01:58:41steven.dapranocreate