Ben's right regarding the facts. Here's my examples.

Python 3.6.9 (default, Jul 17 2020, 12:50:27)
    >>> def foo(*argv, **kwargs): return argv, kwargs
    >>> foo(*'ab', x=1, y=2, *'cd', z=3)
    (('a', 'b', 'c', 'd'), {'x': 1, 'y': 2, 'z': 3})

Python 2.7.17 (default, Jul 20 2020, 15:37:01)
    >>> def foo(*argv, **kwargs): return argv, kwargs
    >>> foo(*'ab', x=1, y=2, *'cd', z=3)
    SyntaxError: invalid syntax

Also, in Python 3.6.9
    >>> foo(**{}, *())
is a SyntaxError, but
    >>> foo(x=1, *())
is not.

I think the change happened as a result of
PEP 448 -- Additional Unpacking Generalizations
https://www.python.org/dev/peps/pep-0448/

It reads, in part,

> Function calls may accept an unbounded number of * and ** unpackings.
> There will be no restriction of the order of positional arguments with
> relation to * unpackings nor any restriction of the order of keyword
> arguments with relation to ** unpackings.


Ben also asked: This is against the understanding of unpacking, is this
intentional?

I was surprised at the unpacking behaviour. My first thought was that Ben
had made some mistake regarding the facts. So I made the check you see
above.
-- 
Jonathan
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/W2ACGW2RCK4RQUZTKPXD6Z3O4H4HDS5A/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to