On Fri, 12 Mar 2021 at 15:53, Paul Bryan <pbr...@anode.ca> wrote:
>
> My inclination would be to cede code formatting to a tool like Black and 
> focus on function:
> https://black.readthedocs.io/en/stable/

... and if you try that out, what you'll find is that black adds parentheses:

y = (
    x.rstrip("\n")
    .split(":")[0]
    .lower()
)

Which is a reasonable solution even if you don't like black's
formatting choices. Black only wraps when the line length is exceeded,
but I can see arguments for wrapping sooner than that in some cases,
and personally I prefer the following indentation scheme:

y = (
    x.rstrip("\n")
       .split(":")[0]
       .lower()
)

But the principle is the same - I think adding parentheses is an
acceptable compromise, in the spirit of "Special cases aren't special
enough to break the rules".

I don't like needing to use backslashes to continue lines, but I find
having to think about how to structure my code to avoid continuations
that need backslashes tends to force me to come up with better/more
readable ways of writing the expression. Chained method calls are
right at the limit here. Sometimes (and only sometimes!) they are a
nice way of expressing a computation, but there's no immediately
natural way to line-wrap them. I can sympathise with the request here,
but parentheses seem adequate to me. (And yes, I spotted the irony of
suggesting paren-delimiters for extended expressions in a language
that avoids using braces as delimiters for statement blocks :-))

Paul
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/W4A7TKADGRMHGYOKTI2FYR7N2JLMBEWN/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to