Issue 3473: In function call, keyword arguments could follow *args (original) (raw)

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

Files
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): pass parameters can appear after the *arg, they are required to be passed by keyword. 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 http://mail.python.org/pipermail/python-3000/2008-July/014437.html
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: Alyssa 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
Ping!
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: http://mail.python.org/pipermail/python-3000/2008-July/014506.html
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) http://hg.python.org/cpython/rev/3ae399c6ecf6
History
Date User Action Args
2022-04-11 14:56:37 admin set github: 47723
2014-08-28 04:07:25 python-dev set nosy: + python-devmessages: +
2014-08-27 10:53:00 mjpieters set nosy: + mjpietersmessages: +
2008-09-04 06:59:12 amaury.forgeotdarc set messages: +
2008-09-03 18:28:31 jcea set nosy: + jcea
2008-08-19 21:26:12 benjamin.peterson set messages: +
2008-08-19 20:57:30 benjamin.peterson set messages: +
2008-08-19 19:53:03 benjamin.peterson set status: open -> closedmessages: +
2008-08-19 19:31:36 barry set resolution: acceptedmessages: +
2008-08-17 22:10:12 amaury.forgeotdarc set assignee: rhettinger -> amaury.forgeotdarcmessages: + nosy: + barry
2008-08-16 06:39:16 georg.brandl set nosy: + georg.brandlmessages: +
2008-08-13 18:09:21 terry.reedy set nosy: + terry.reedymessages: +
2008-08-01 21:47:09 amaury.forgeotdarc set assignee: amaury.forgeotdarc -> rhettingermessages: +
2008-07-31 14:38:14 ncoghlan set nosy: + ncoghlanmessages: +
2008-07-31 13:54:25 benjamin.peterson set nosy: + benjamin.petersonmessages: +
2008-07-31 13:13:28 amaury.forgeotdarc set files: + kwargs26.patchmessages: +
2008-07-31 13:12:44 amaury.forgeotdarc set files: + kwargs30.patchkeywords: + patch
2008-07-31 06:31:28 rhettinger set nosy: + rhettingermessages: +
2008-07-31 01:30:54 amaury.forgeotdarc set messages: +
2008-07-31 01:16:30 amaury.forgeotdarc create