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

Simon Sapin simon.sapin at kozea.fr
Sat Mar 3 16:47:21 CET 2012

Le 03/03/2012 16:20, Ron Adam a écrit :
> It seems to me that sometimes the writer of functions wish to have more
> control of how the function is called, but I think it is better that the
> user of a function can select the calling form that perhaps matches the
> data and/or style they are using more closely.

I agree with that, but it can still make sense to have positional-only 
arguments. For example, we want d.update(self=4) to update the 'self' 
key on any Mapping, so the default implementation update on the ABC has 
to accept *args, **kwargs and have some code to extract self:


Without this "hack", passing self=4 would give TypeError: got multiple 
values for keyword argument 'self'.

It would be so much nicer to be able to declare self and other 
positional-only in "def update(self, other=(), **kwargs):"

Simon Sapin

More information about the Python-ideas mailing list