More informative error messages (Re: [Python-Dev] Efficient predicates for the standard library)

Greg Ewing greg at
Mon Oct 6 20:33:19 EDT 2003

Alex Martelli <aleaxit at>:

> Python's error messages are slowly but surely getting better in that,
> instead of just saying that something (e.g.) "must be int" (and
> leaving the coder in the dark about WHAT it was instead)

While we're on the subject of error messages, I'd like to
point out another one that could be improved. Often one
sees things like

  TypeError: foo() takes exactly 1 argument (2 given)

In the case where foo() is a method of some class, and there
are various versions of foo() defined in various superclasses,
it's sometimes hard to tell exactly *which* foo it was trying
to call. It would be much more useful if the module and
class names were included in the error message, e.g.

  TypeError: takes exactly 1 argument (2

The same goes for function names quoted in the traceback.

Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | A citizen of NewZealandCorp, a	  |
Christchurch, New Zealand	   | wholly-owned subsidiary of USA Inc.  |
greg at	   +--------------------------------------+

More information about the Python-Dev mailing list