[Python-ideas] Positional only arguments
Steven Bethard
steven.bethard at gmail.com
Sat May 19 08:40:38 CEST 2007
On 5/18/07, Talin <talin at acm.org> wrote:
> Steven Bethard wrote:
> > Not sure I understand the question. My point was only that you'll
> > never reproduce this behavior::
> >
> > >>> dict(self=1, other=2)
> > {'self': 1, 'other': 2}
> > >>> d = {}
> > >>> d.update(container=2, sequence=1)
> > >>> d
> > {'container': 2, 'sequence': 1}
> >
> > Of course, you can rename the 'self' and 'container' parameters to
> > something else, but that just means that you can't use whatever new
> > names you choose. The only way to solve this is to use real
> > positional-only arguments, which currently means using *args and
> > parsing out things within the function body.
>
> I would just use names beginning with an underscore, or some other
> convention that is unlikely to occur as a dict key.
So should I take that as a +1 for:
* Enforce double-underscore names as being positional-only syntactically, e.g.::
def f(__a, __b=None, *, c=42, **kwargs)
Pro: requires no new syntax
Con: slightly backwards incompatible (but who calls f(__a) anyway?)
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