Terry J. Reedy <tjre...@udel.edu> added the comment:

Stephen is right; this sort of guess-the-bug heuristic is out of scope for the 
CPython interpreter. I believe you grossly under estimate the difficulty of 
such a this. Consider that idea rejected.

What *is* disconcerting is the exact form of the error message for this 
particular code pattern:

Traceback (most recent call last):
  File "<pyshell#0>", line 3, in <module>
    (4, 5, 6)
TypeError: 'tuple' object is not callable

Uh... There was no attempt to call the tuple (4,5,6), which was misinterpreted 
as a () call operator with 3 args. What might be a reasonable request is to 
print a size-limited representation of the object that is not callable but was 
attempted to be called. Truncated representations would be generally useful for 
traceback messages. I believe we already have them for unittest error messages.

A useful document for someone (or some people) to write would be 'How to 
interpret exception messages'. That could start with a catalog of messages and 
possible causes. 'type' would be used to stand for any specific type.

The section on TypeErrors would have an heading
  'type' object is not callable
followed by an explanation
  There are two general reasons for this message. The first is that you 
intentionally write "expression(args)" with the intent that expression evaluate 
to a callable, but it does not. The second is that you accidentally omit a 
comma in a sequence and write "expression (tuple_members)". Note that the error 
is triggered by the "(args)" call operator and its line is the one printed. So 
if "expression" is on the preceeding line, it will not appear in the traceback. 
This can happen with either type of error.

In the meanwhile, the above is a start for a faq entry.

----------
nosy: +terry.reedy

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue15248>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to