[Python-ideas] Inline assignments using "given" clauses

Chris Angelico rosuav at gmail.com
Fri May 11 09:42:50 EDT 2018

On Fri, May 11, 2018 at 11:34 PM, Rhodri James <rhodri at kynesim.co.uk> wrote:
> On 11/05/18 14:25, Jacco van Dorp wrote:
>> I actually have to mentally parse the entire line to get what the
>> check will work. This, along with what Chris said about order of
>> operations, reduce the readability of the "given" version.
> You say "I had to parse the entire line..."   I hear "I had to read what I
> was making a snap decision on."  Sounds like a win :-)

No, not a win. Do you read the entire source code for an entire
project before trying to comprehend one part of it? I doubt it. Do you
read an entire file before trying to comprehend a single function in
that file? No. Do you even read an entire function before processing
one line in that function? Unlikely. It's normal and correct to seek
to understand one part of some code while ignoring other parts. That's
why we have proper variable names, even inside functions - we could
just use "slot0" and "slot1" and so on, since that's how they work to
the interpreter. But we use good names, so that you can understand
some code without having to first read the thing that created that


More information about the Python-ideas mailing list