<div dir="ltr"><div>I have encountered situations like this, and generally I just use **kwargs for non-critical  and handle the parameter management in the body of the function.</div><div><br></div><div>This also makes it easier to pass the arguments to another function.  You can use a dict comprehension to copy over the keys you want, then unpack them as arguments to the next function.<br></div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Sep 6, 2018 at 6:16 AM Anders Hovmöller <<a href="mailto:boxed@killingar.net">boxed@killingar.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I have a working implementation for a new syntax which would make using keyword arguments a lot nicer. Wouldn't it be awesome if instead of:<br>
<br>
        foo(a=a, b=b, c=c, d=3, e=e)<br>
<br>
we could just write:<br>
<br>
        foo(*, a, b, c, d=3, e)<br>
<br>
and it would mean the exact same thing? This would not just be shorter but would create an incentive for consistent naming across the code base. <br>
<br>
So the idea is to generalize the * keyword only marker from function to also have the same meaning at the call site: everything after * is a kwarg. With this feature we can now simplify keyword arguments making them more readable and concise. (This syntax does not conflict with existing Python code.)<br>
<br>
The full PEP-style suggestion is here: <a href="https://gist.github.com/boxed/f72221e7e77370be3e5703087c1ba54d" rel="noreferrer" target="_blank">https://gist.github.com/boxed/f72221e7e77370be3e5703087c1ba54d</a><br>
<br>
I have also written an analysis tool you can use on your code base to see what kind of impact this suggestion might have. It's available at <a href="https://gist.github.com/boxed/610b2ba73066c96e9781aed7c0c0b25c" rel="noreferrer" target="_blank">https://gist.github.com/boxed/610b2ba73066c96e9781aed7c0c0b25c</a> . The results for django and twisted are posted as comments to the gist. <br>
<br>
We've run this on our two big code bases at work (both around 250kloc excluding comments and blank lines). The results show that ~30% of all arguments would benefit from this syntax.<br>
<br>
Me and my colleague Johan Lübcke have also written an implementation that is available at: <a href="https://github.com/boxed/cpython" rel="noreferrer" target="_blank">https://github.com/boxed/cpython</a> <br>
<br>
/ Anders Hovmöller<br>
_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org" target="_blank">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">http://python.org/psf/codeofconduct/</a><br>
</blockquote></div>