[Python-ideas] Passing positional arguments as keyword arguments (to provide function arguments out of order)

Brett Cannon brett at python.org
Wed May 15 12:50:15 EDT 2019


On Wed, May 15, 2019 at 12:46 AM Anders Hovmöller <boxed at killingar.net>
wrote:

>
>
> > On 15 May 2019, at 07:51, Jonathan Goble <jcgoble3 at gmail.com> wrote:
> >
> > That's not a realistic goal; there are some use cases, including in
> > CPython builtins, that cannot be accomplished without positional-only
> > arguments. For example, the current behavior of the `dict` constructor
> > is to accept both certain iterables as a positional-only argument
> > and/or keyword arguments from which a dict can be created. If the
> > iterable argument was not positional-only, then it would be forced to
> > consume a keyword (even if the caller passes it as a positional
> > argument), meaning that that keyword could never be included in
> > **kwargs and could not become a dict key via keyword arguments.
>
> You lost me. How is this not handled by *args and **kwargs? I think it is.
> "Positional only" isn't needed in this case.
>
> > Additionally, PEP 570 [1], which will add syntax for positional-only
> > parameters in Python functions, was accepted by Guido last month.
>

It was actually a decision of the Python steering council, of which Guido
is a member and so am I.


>
> I know and in my opinion it's a big mistake. It adapts python to a
> misfeatures of C extension code instead of making the C extentions play
> nice end behave like python.


There's actually more to it than that (it actually resolves various bugs we
had in the stdlib that have nothing to do with C extension modules). The
details can be found in the PEP.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20190515/1f057351/attachment.html>


More information about the Python-ideas mailing list