[Python-ideas] Improving fn(arg=arg, name=name, wibble=wibble) code
mike at selik.org
Thu Sep 13 22:07:33 EDT 2018
On Thu, Sep 13, 2018 at 5:22 PM Anders Hovmöller <boxed at killingar.net>
> For example:
> django-master/django/http/multipartparser.py 225
Sorry, I didn't recognize this as a link on first read. I'll provide a link
here to the code in context.
This is a fairly large function that might benefit from being refactored to
clarify the code. On the other hand, I don't advocate creating too many
helper functions with only one callsite. The one thing that catches my eye
is the repeated use of ``exhaust`` in the else clause to several layers of
the nested try and if blocks.
It's a bit too large for me to make sense of it quickly. My apologies for
not offering a holistic refactor.
That’s positional because keyword is more painful.
Why would keyword arguments be more painful here? They've already split the
call across 4 lines. Why not go a bit further and use keyword args to make
it 6 or 7 lines? Maybe they decided it reads fine as it is.
Sure. Run this script against django:
> It will print all function calls that are positional and have > 2
> arguments. Not a single one is good as is, all would be better with keyword
I disagree. Please expand your assertion by explaining why an example is
not good as-is and would be better with keyword arguments.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas