[Python-ideas] Improving fn(arg=arg, name=name, wibble=wibble) code

Anders Hovmöller boxed at killingar.net
Thu Sep 13 20:34:28 EDT 2018



> On 13 Sep 2018, at 21:34, Michael Selik <mike at selik.org> wrote:
> 
> On Thu, Sep 13, 2018 at 11:35 AM Anders Hovmöller <boxed at killingar.net <mailto:boxed at killingar.net>> wrote:
>> Using keyword arguments is not painful. It's ugly in some unusual cases, such as creating helper functions with nearly the same signature.
> 
> It’s more painful than positional. To me the fact that everyone who works on code bases that are of non-trivial size see positional arguments being used for calls with more than 3 arguments is a pretty obvious proof.
> 
> Looking through my recent code, I find I rarely call functions passing more than 3 arguments, unless using * or ** unpacking. This might be part of the difference in our styles.

I wrote a script so you can get a list of them all in big code bases without looking through the code randomly. https://gist.github.com/boxed/e60e3e19967385dc2c7f0de483723502 <https://gist.github.com/boxed/e60e3e19967385dc2c7f0de483723502> 

> 
> I feel this pain daily. You aren’t me so you can’t say if I feel this or not. 
> 
> Yes, of course. Pain is subjective. Are you aware that changing Python syntax is painful for not only the implementers, but also the users? 

Let’s not exaggerate here. I’ve already implemented my original proposed syntax, and I’m pretty sure the =foo syntax is similarly easy (if not easier!) to implement. It took me something like one hour and I haven’t coded C for 20 years, 7 years if you count C++, and I’ve never looked at the CPython code base before. It’s not that painful to implement.

As for users I don’t buy that argument much either. We aren’t optimizing for not changing the language just to make people not learn new things. See f-strings, assignment expressions, new except syntax, matrix multiplication operator. We are optimizing for the value of python. Or, that’s how I see it anyway. 

/ Anders
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180914/67e5daa9/attachment.html>


More information about the Python-ideas mailing list