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.

Title: In function call, keyword arguments could follow *args
Type: Stage:
Components: Versions: Python 3.0
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: amaury.forgeotdarc Nosy List: amaury.forgeotdarc, barry, benjamin.peterson, georg.brandl, jcea, mjpieters, ncoghlan, python-dev, rhettinger, terry.reedy
Priority: normal Keywords: patch

Created on 2008-07-31 01:16 by amaury.forgeotdarc, last changed 2022-04-11 14:56 by admin. This issue is now closed.

File name Uploaded Description Edit
kwargs30.patch amaury.forgeotdarc, 2008-07-31 13:12
kwargs26.patch amaury.forgeotdarc, 2008-07-31 13:13
Messages (17)
msg70449 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2008-07-31 01:16
functions with keyword-only arguments have this form:
    def f(x, *args, y):
parameters can appear after the *arg, they are required to be passed by

It would be more consistent to allow this function call:
    f(X, *ARGS, y=Y)
This is invalid syntax, *ARGS is required to be at the end of the
arguments, together with an eventual **KWARGS. This restriction should
be lifted.

See the use case in
msg70451 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2008-07-31 01:30
Should this apply to 2.6 as well? See r65321, I find the last line
easier to read when arguments are in this order.

    def grouper(n, iterable, fillvalue=None):
        args = [iter(iterable)] * n
        return izip_longest(*args, fillvalue=fillvalue)

On the cons side, keyword-only arguments don't exist in 2.6, so the
consistency with function definition syntax does not apply.
msg70485 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2008-07-31 06:31
+1 for applying to 2.6.  

izip_longest() is a perfect example of where it's important.
msg70499 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2008-07-31 13:13
Patches for both versions are attached.
msg70502 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2008-07-31 13:54
The patches look good to me.
msg70510 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2008-07-31 14:38
I'll have a look at this in the next day or two.
msg70597 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2008-08-01 21:47
I will not have internet access for the next week. 
Raymond, would you take care of this issue?
msg71094 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2008-08-13 18:09
Another use case: upon reading A.Baxter's Porting to 3 talk, I realized,
slightly generalizing from his example, that
print(s.join(map(str,it))) == print(*it,sep=s) -- or would, except that
it currently has to be written non-intuitively as print(sep=s,*it),
which I might not have tried except for knowing about this issue.

Given that many have problems with .join and that most uses are to
produce immediate output not otherwise processed, I think having the
replacement work in the way many would expect would be a win.
So I hope this makes the next beta.
msg71198 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2008-08-16 06:39
msg71293 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2008-08-17 22:10
Barry, is it still time for this to be included in 2.6b3?
Guido already approved the idea:
msg71471 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2008-08-19 19:31
Guido's approved it, so please go ahead and add it before beta 3.
msg71473 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2008-08-19 19:53
Applied for 2.6 in r65872.
msg71481 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2008-08-19 20:57
Done for py3k in r65877.
msg71486 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2008-08-19 21:26
Now test_compiler is breaking for us because the compiler package can't
handle the change.
msg72485 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2008-09-04 06:59
The compiler package was fixed some time ago with r65891
msg225968 - (view) Author: Martijn Pieters (mjpieters) * Date: 2014-08-27 10:53
The documentation change in this patch introduced a bug in the Call grammar:

| "*" `expression` ["," "*" `expression`] ["," "**" `expression`]

instead of

| "*" `expression` ["," `keyword_arguments`] ["," "**" `expression`]

giving the impression that `*expression` is allowed twice.
msg226009 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-08-28 04:07
New changeset 3ae399c6ecf6 by Benjamin Peterson in branch '2.7':
correct call grammar error (#3473)
Date User Action Args
2022-04-11 14:56:37adminsetgithub: 47723
2014-08-28 04:07:25python-devsetnosy: + python-dev
messages: + msg226009
2014-08-27 10:53:00mjpieterssetnosy: + mjpieters
messages: + msg225968
2008-09-04 06:59:12amaury.forgeotdarcsetmessages: + msg72485
2008-09-03 18:28:31jceasetnosy: + jcea
2008-08-19 21:26:12benjamin.petersonsetmessages: + msg71486
2008-08-19 20:57:30benjamin.petersonsetmessages: + msg71481
2008-08-19 19:53:03benjamin.petersonsetstatus: open -> closed
messages: + msg71473
2008-08-19 19:31:36barrysetresolution: accepted
messages: + msg71471
2008-08-17 22:10:12amaury.forgeotdarcsetassignee: rhettinger -> amaury.forgeotdarc
messages: + msg71293
nosy: + barry
2008-08-16 06:39:16georg.brandlsetnosy: + georg.brandl
messages: + msg71198
2008-08-13 18:09:21terry.reedysetnosy: + terry.reedy
messages: + msg71094
2008-08-01 21:47:09amaury.forgeotdarcsetassignee: amaury.forgeotdarc -> rhettinger
messages: + msg70597
2008-07-31 14:38:14ncoghlansetnosy: + ncoghlan
messages: + msg70510
2008-07-31 13:54:25benjamin.petersonsetnosy: + benjamin.peterson
messages: + msg70502
2008-07-31 13:13:28amaury.forgeotdarcsetfiles: + kwargs26.patch
messages: + msg70499
2008-07-31 13:12:44amaury.forgeotdarcsetfiles: + kwargs30.patch
keywords: + patch
2008-07-31 06:31:28rhettingersetnosy: + rhettinger
messages: + msg70485
2008-07-31 01:30:54amaury.forgeotdarcsetmessages: + msg70451
2008-07-31 01:16:30amaury.forgeotdarccreate