[Python-ideas] Positional only arguments

Steven Bethard steven.bethard at gmail.com
Mon May 21 09:08:58 CEST 2007


On 5/21/07, Adam Olsen <rhamph at gmail.com> wrote:
> now I think there's a bigger problem: it undermines the obviousness of
> PEP 3102's behaviour.
>
> Consider this example:
>
>     def compare(a, b, *args, key=None):
>
> Although not legal today, the behaviour is obvious.  All positional
> arguments get sucked up in *args so key *must* be keyword-only.

This may not be so obvious anymore now that we have extended iterable
unpacking from `PEP 3132`_.  Given an iterable unpacking like::

    a, b, *c, d = iterable

I may assume that names after a *args work just like names before one::

    def f(a, b, *c, d)

So in this case I'd assume that the 'd' is also positional, not keyword-only.

Again, I'm not saying people can't learn the appropriate meaning, just
that it's not inherently obvious.

.. _PEP 3132: http://www.python.org/dev/peps/pep-3132/

STeVe
-- 
I'm not *in*-sane. Indeed, I am so far *out* of sane that you appear a
tiny blip on the distant coast of sanity.
        --- Bucky Katt, Get Fuzzy



More information about the Python-ideas mailing list