Functions does not accept keyword arguments if an argument list specified
Manuel M. Garcia
mail at manuelmgarcia.com
Sun Feb 16 22:55:05 EST 2003
On Sun, 16 Feb 2003 23:17:39 +0100, Létezõ <letezo at fw.hu> wrote:
(edit)
>>>> def fn(*args,**kw): print 'args=%r, kw=%r'%(args,kw)
>...
>>>> fn(1,2,a=3,b=4)
>args=(1, 2), kw={'a': 3, 'b': 4}
>>>> al=[1,2]
>>>> kd={'a':3,'b':4}
>>>> fn(*al,**kd)
>args=(1, 2), kw={'a': 3, 'b': 4}
>>>> fn(1,2,**kd)
>args=(1, 2), kw={'a': 3, 'b': 4}
>>>> fn(*al,a=3,b=4)
> File "<stdin>", line 1
> fn(*al,a=3,b=4)
> ^
>SyntaxError: invalid syntax
*args and **kw like to be last:
>>> fn(a=3,b=4,*a1)
args=(1, 2), kw={'a': 3, 'b': 4}
but I am pretty sure Guido considers the SyntaxError you found to be a
bug. I remember reading he had some examples of completely
generalizing the syntax, but I forgot where I read it.
Manuel
More information about the Python-list
mailing list