On Tuesday 07 October 2003 02:33 am, Greg Ewing wrote: > Alex Martelli <aleaxit at yahoo.com>: > > 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: MyStuff.SomeClass.foo() takes exactly 1 argument (2 > given) A perennial beginners' confusion (recently highlighted in a c.l.py thread whose subject claimed that Python can't count;-) is about that "number of arguments given" number: one calls zoop.bleep() and is told bleep "takes exactly 2 arguments (1 given)" when one is sure that one has given no argument at all (and should give exactly 1) -- the implied 'self' causing the beginners' confusion. It seems to me that, if we work on these messages, we may be able to distinguish the bound-method case into TypeError: bound method bleep() of Zoop instance takes exactly 1 argument (0 given) or some such... Alex
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4