This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author brandtbucher
Recipients brandtbucher
Date 2019-10-23.00:20:41
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1571790042.34.0.496395652559.issue38560@roundup.psfhosted.org>
In-reply-to
Content
Calls of the form f(name=value, *args) are currently legal syntax. The resulting argument binding is awkward, and almost never does what you want/expect it to:

>>> def f(x, y, z):
...     print(x, y, z)
... 

>>> f(x=0, *(1, 2))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: f() got multiple values for argument 'x'

>>> f(y=0, *(1, 2))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: f() got multiple values for argument 'y'

>>> f(z=0, *(1, 2))
1 2 0

I'm not sure if this is intentional, or an oversight. Every other way of passing positional arguments after keyword arguments results in an error:

f(kwarg=kwarg, arg)  # SyntaxError: positional argument follows keyword argument
f(**kwargs, arg)     # SyntaxError: positional argument follows keyword argument unpacking
f(**kwargs, *args)   # SyntaxError: iterable argument unpacking follows keyword argument unpacking

I think this case should raise a "SyntaxError: iterable argument unpacking follows keyword argument".

I'd like to work on this if we believe it should be changed.
History
Date User Action Args
2019-10-23 00:20:42brandtbuchersetrecipients: + brandtbucher
2019-10-23 00:20:42brandtbuchersetmessageid: <1571790042.34.0.496395652559.issue38560@roundup.psfhosted.org>
2019-10-23 00:20:42brandtbucherlinkissue38560 messages
2019-10-23 00:20:41brandtbuchercreate