[Python-Dev] A grammatical oddity: trailing commas in argument lists -- continuation (original) (raw)
Jan Kaliszewski zuo at chopin.edu.pl
Mon Dec 13 12:44:49 CET 2010
- Previous message: [Python-Dev] [Python-checkins] r87202 - python/branches/py3k/Doc/library/logging.rst
- Next message: [Python-Dev] A grammatical oddity: trailing commas in argument lists -- continuation
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Dear Python Developers,
It is s my first post to python-dev, so let me introduce myself briefly: Jan Kaliszewski, programmer and composer, sometimes also NGO activist.
Coming to the matter... The discussion started with remark by Mark Dickinson about such a syntax oddity:
def f(a, b,): ... is fine, but def f(*, a, b,): ... is a SyntaxError
Then some other similar oddities were pointed at (*args/*kwargs-related ones as well as calls like f(, a=3,) causing SyntaxError too).
References:
- http://mail.python.org/pipermail/python-dev/2010-July/101636.html
- http://bugs.python.org/issue9232
- http://bugs.python.org/issue10682
But yesterday both mentioned issues has been closed as rejected -- with suggestion that it would probably require a PEP to modify Python in this aspect (as there is no clear consensus). So I'd opt for re-opening the discussion -- I suppose that more people could be interested in solving the issue (at least after the end of PEP 3003 moratorium period).
I think that seeing that:
def f(a, b): ...
def f(a, b,): ...
def f(a, *, b): ...
def f(a, *args, b): ...
x(1, 2, 3, 4, z=5)
x(1, 2, 3, 4, z=5,)
x(1, *(2,3,4), z=5)
...are ok, then --
def f(a, *, b,): ...
def f(a, *args, b,): ...
x(1, *(2,3,4), z=5,): ...
...should be ok as well, and consequently --
def f(a, *args,): ...
def f(a, **kwargs,): ...
x(1, *(2,3,4),)
x(1, **dict(z=6),)
...should also be ok.
Please also note that Py3k's function annotations make one-def-argument- -per-line formattig style the most suitable in some cases, e.g.:
def my_func(
spam:"Very tasty and nutritious piece of food",
ham:"For experts only",
*more_spam:"Not less tasty and not less nutritious!",
spammish_inquisition:"Nobody expects this!",
) -> "Spam, spam, spam, spam, spam, spam, spam, spam, spam, spam":
...
Regards,
Jan Kaliszewski
- Previous message: [Python-Dev] [Python-checkins] r87202 - python/branches/py3k/Doc/library/logging.rst
- Next message: [Python-Dev] A grammatical oddity: trailing commas in argument lists -- continuation
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]