[Python-ideas] Positional only arguments

Adam Olsen rhamph at gmail.com
Tue May 22 03:52:46 CEST 2007


On 5/21/07, Steven Bethard <steven.bethard at gmail.com> wrote:
> Just for reference, here are the current motivating use cases:
>
> * User mapping types that need to match the dict() and dict.update()
> method signatures

I wasn't aware the proposals given would meet this use case!  PEP 3102
has no effect on correct code, instead it just adds some error
detection for incorrect code.  In contrast, the dict()/dict.update()
signature use case needs semantics to change for an example like this:

  def x((a=None), **kwargs): ...
  x(a=3)

This can't be wrapped properly without very special care.  For
instance, this would behave wrong:

  def method(self, *args, **kwargs):
    x(*args, **kwargs)

I'm strongly against adding a feature to split **kwargs into a
separate namespace when we have such a common convention of NOT doing
it for self[1][2].  The decorator proposed in the other thread is a
much better solution unless we want to overturn that convention.


[1] Google codesearch for "self[^()]*\*\* lang:python" returned 28,800
results.. make that 200 results.. or 186 results.. numbers aren't too
accurate it seems.
[2] "\([a-z][^()]*\*\* lang:python" claims 29,500, but won't let me go
past 200 results.  Maybe there's an internal limiter?

-- 
Adam Olsen, aka Rhamphoryncus



More information about the Python-ideas mailing list