[Python-ideas] keyword arguments everywhere (stdlib) - issue8706

Antoine Pitrou solipsis at pitrou.net
Sun Mar 4 17:57:58 CET 2012


On Sun, 4 Mar 2012 13:46:33 +1000
Nick Coghlan <ncoghlan at gmail.com> wrote:
> 
> Then the "_unpack_args" hack above would be unnecessary, and you could
> just write:
> 
>     class C:
> 
>         def __init__(*(self, data=None), **kwds):
>             self._stored_data = stored = {}
>             if data:
>                 stored.update(data)
>             stored.update(kwds)
> 
>         def update(*(self, data=None), **kwds):
>             stored = self._stored_data
>             if data is not None:
>                 stored.update(data)
>             stored.update(kwds)
> 
> The objection was raised that this runs counter to the philosophy
> behind PEP 3113 (which removed tuple unpacking from function
> signatures). I disagree:
> - this is not tuple unpacking, it is parameter binding
> - it does not apply to arbitrary arguments, solely to the "extra
> arguments" parameter, which is guaranteed to be a tuple
> - it allows positional-only arguments to be clearly expressed in the
> function signature, allowing the *interpreter* to deal with the
> creation of nice error messages
> - it *improves* introspection, since the binding of positional only
> arguments is now expressed clearly in the function header (and
> associated additional metadata on the function object), rather than
> being hidden inside the function implementation

Then please consider also re-introducing parameter tuple unpacking,
since that was genuinely useful.

Regards

Antoine.





More information about the Python-ideas mailing list