osdir.com

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Python-Dev] Error message for wrong number of arguments


On Mon, Jul 30, 2018 at 5:12 AM, Jeroen Demeyer <J.Demeyer at ugent.be> wrote:

> I think it has been argued before that it's a feature that self is
> counted.


I suppose it is, as it's technically correct, but it's also a HUGE source
of confusion, particularly for newbies. IF this is being touched anyway, is
it possible for the interpreter to know when this error is generated that
this is a bound method expecting a "self", rather than an arbitrary
function with n parameters? In which case, it would be really nice if the
error message replaced that somehow, maybe something like:

>>> g(1,2)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: append() takes 1 positional argument in addition to the
automatically added instance object --  but 2 were given in addition to the
object instance.

Man -- hard to come up with good wording for that -- but SOMETHING that
lets users know what they actually did wrong would be good :-)

If it's not do-able, then still +1 on making builtins consistent.

-CHB

-- 

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20180730/b66660b7/attachment.html>