[Python-ideas] PEP for issue2292, "Missing *-unpacking generalizations"

Joshua Landau joshua.landau.ws at gmail.com
Sun Jul 7 01:03:40 CEST 2013


On 6 July 2013 23:20, Joshua Landau <joshua.landau.ws at gmail.com> wrote:
> Then should we expand to allow arbitrary mixing of keyword and
> positional arguments (which sounds reasonable if we want to allow
> keyword arguments before *args, and also treat *args like any
> positional argument)?

To give more hints as to what I am saying:

Original Proposal::

    Function calls may accept an unbound number of ``*`` and ``**``
unpackings, which are allowed anywhere that positional and keyword
arguments are allowed respectively. In approximate pseudo-notation::

        function(
            argument or *args, argument or *args, ...,
            kwargument or **kwargs, kwargument or **kwargs, ...
        )

    This has been rejected, primarily as it is not worth the
backwards-incompatibility.

Status Quo::

    Function calls may accept an unbound number of ``*`` and ``**``
unpackings. Keyword-arguments must follow positional arguments, and
``**`` unpackings must also follow ``*`` unpackings. In approximate
pseudo-notation::

        function(
            argument or *args, argument or *args, ...,
            kwargument or *args, kwargument or *args, ...,
            kwargument or **kwargs, kwargument or **kwargs, ...
        )

Looser rulings::

    Function calls may accept an unbound number of ``*`` and ``**``
unpackings. Arguments can now occur in any position in a function
call. As usual, keyword arguments always go to their respective keys
and positional arguments are then placed into the remaining positional
slots. In approximate pseudo-notation::

        function(
            argument or keyword_argument or *args or **kwargs,
            argument or keyword_argument or *args or **kwargs,
            ...
        )


More information about the Python-ideas mailing list