On Thu, 20 May 2010 11:49:02 +0200, =?ISO-8859-1?Q?Giampaolo_Rodol=E0?= <g.rod...@gmail.com> wrote: > 2010/5/20 John Arbash Meinel <john.arbash.mei...@gmail.com>: > >>>>> a.echo() > >> Traceback (most recent call last): > >> =A0 File "<stdin>", line 1, in <module> > >> TypeError: echo() takes exactly 2 arguments (1 given) > >> > >> I bet my last 2 cents this has already been raised in past but I want > >> to give it a try and revamp the subject anyway. > >> Is there a reason why the error shouldn't be adjusted to state that > >> *1* argument is actually required instead of 2? > > > > Because you wouldn't want to have > > > > A.echo() > > > > Say that it takes 1 argument and (-1 given) ? > > I see that as a different error type: what you're doing there is > calling a method of a class which you haven't instantiated in the > first place. > Actually the error message returned in this other case is not very > clear as well: > > "unbound method echo() must be called with A instance as first > argument (got nothing instead)" > > It talks about "arguments" while no arguments are actually involved in > the problem: just a class I forgot to initialize.
That second message is entirely accurate and IMO should not be changed. As Michael said, calling an unbound method is not that uncommon. The problem with fixing the first message (as you will see if you read issue 2516) is that it turns out to be non-trivial to do it right. Otherwise I think it would have been fixed already. -- R. David Murray www.bitdance.com _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com