[Python-ideas] Keyword only argument on function call

Brice Parent contact at brice.xyz
Tue Sep 11 05:13:37 EDT 2018

> For this case, I kinda like Steve Barnes idea (I think it is his) to 
> have a "magic object of some type, so you can have BOTH specified 
> parameters, and easy access to the *args, **kwargs objects. Though I'm 
> also wary of the magic...
> Perhaps there's some way to make it explicit, like "self":
> def fun(a, b, c, d=something, e=something, &args, &&kwargs):
Another possiblity would be to be able to have alternative signatures 
for a single function, the first being the one shown in inspection and 
for auto-completion, the other one(s?) just creating new references to 
the same variables. Like this:

def fun(a, b, c, d=something1, e=something2, f=something3)(_, *args, 
e=something2, **kwargs):
     # do whatever you need
     assert args[0] == b
     assert kwargs["d"] == something1
     super().fun("foo", *args, e="bar", **kwargs)

I'm not sure what would happen if we didn't provide the same defaults 
for `e` in the two signatures (probably an exception).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180911/486ccff4/attachment.html>

More information about the Python-ideas mailing list