[Python-ideas] Positional only arguments

Steven Bethard steven.bethard at gmail.com
Mon May 21 09:15:49 CEST 2007


On 5/21/07, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> I think the desire for positional-only args would be
> addressed well enough using a naming convention. Even
> without further explanation, if I saw something like
>
>    def f(_a, _b, _c):
>      ...
>
> it would be pretty clear to me that the author intended
> the parameter names to be an implementation detail.

So what about the signature for dict() and dict.update() where you
want to write::

    def update(self, container=None, **kwargs)

Note that I shouldn't want to write '__container' because it's not an
implementation detail.  It's a valid positional argument that my
clients can use.  But if I write 'container', then I'm limiting what
they can send as **kwargs and I can't reproduce the dict behavior::

    >>> d = {}
    >>> d.update(container=1)
    >>> d
    {'container': 1}

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