Nick Coghlan <[email protected]> added the comment:
Having seen the reversion go by on the checkins list, I think there are
distinctions the interpreter should be making here in order to improve the
error messages, but it isn't.
Ideally, we want to be able to tell the user (without writing War and Peace as
an error message):
1. How many positional parameters are expected
2. How many positional parameters were supplied as positional arguments
3. How many positional parameters were supplied as keyword arguments
For example:
Def: f(**kw)
Call: f("hello", keyword=True)
Error: f() does not accept positional arguments (1 given)
Def: f(x, **kw)
Call: f("hello", "goodbye", keyword=True)
Error: f() accepts at most 1 positional argument (2 given)
Def: f(x, **kw)
Call: f("hello", x="goodbye", keyword=True)
Error: f() accepts at most 1 positional argument (2 given, 1 via keyword)
Basically:
1. Get rid of the "exactly"/"at most" distinction ("exactly" is wrong, since
you can always provide positional arguments as keyword arguments instead)
2. Use "positional" instead of the awkward "non-keyword"
3. Append additional info when some or all of the positional arguments are
provided as keywords.
----------
nosy: +ncoghlan
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue9943>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com