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

Michael Selik mike at selik.org
Fri Sep 14 03:26:13 EDT 2018

On Fri, Sep 14, 2018, 12:17 AM Anders Hovmöller <boxed at killingar.net> wrote:

> That's a bit of a dodge. There is a huge difference in verbosity between
> handler.new_file(field_name, file_name, content_type, content_length,
> charset, content_type_extra)
> and
> handler.new_file(field_name=field_name, file_name=file_name,
> content_type=content_type, content_length=content_length, charset=charset,
> content_type_extra=content_type_extra)

Since neither version fits well on one line or even three, I'd have written
each of those on a separate line, indented nicely to emphasize the
repetition. Seems fine to me.

The real problem with this code section wasn't the positional arguments,
but that it was so heavily indented. Whenever I have code so nested, I put
in a great deal of effort to refactor so that I can avoid the nesting of
many try/except, for, and if/else statements.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180914/8d7defe6/attachment.html>

More information about the Python-ideas mailing list