method (a, b = '', *c, **d): gets a syntax error?

Terry Reedy tjreedy at
Fri Aug 29 23:34:22 CEST 2003

"Michael Peuser" <mpeuser at> wrote in message
news:bio39s$2ai$03$1 at
> "Terry Reedy" <tjreedy at> schrieb im Newsbeitrag
> news:3dqcndZe5u2g4NKiXTWJiA at
> [...}
> >
> > 1. When you make a function call and use **whatever, it must be
> > last item in the argument list, just as in a function definition.
> > following comma is not allowed for either defs or calls.
> This in fact is not true. Funnily you can add *one* comma at the end
of any
> list-like construct.

For 2.2.1 and whatever version Andreas is running, **whatever is an
exception and CANNOT be followed by a comma in either def or call,
just as I said.  I tested before writing.   (Did you?  Can you test
below on 2.3?)

>>> def f(**d):
...   for i,v in d.items(): print i, v
>>> b={'one':1, 'two':2}
>>> f(**b)
two 2
one 1
>>> f(**b,)
  File "<stdin>", line 1
SyntaxError: invalid syntax

>>> def f2(**d,): pass
  File "<stdin>", line 1
    def f2(**d,): pass
SyntaxError: invalid syntax

# On the original fixed-pitch font screen, both arrows point at
offending comma.

Can someone verify this for 2.3?  If so, there is a bug in either doc
or interpreter.

Terry J. Reedy

More information about the Python-list mailing list