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

Greg Ewing greg.ewing at canterbury.ac.nz
Fri May 11 03:33:39 EDT 2018


Gustavo Carneiro wrote:
> IMHO, all these toy examples don't translate well to the real world 
> because they tend to use very short variable names while in real world 
> [good written code] tends to select longer more descriptive variable names.

I don't believe that's always true. It depends on the context.
Sometimes, using long variable names can make code *harder*
to read.

I don't think there's anything unrealistic about this
example:

    if m given m = pattern.match(the_string):
       nugget = m.group(2)

Most people's short-term memory is good enough to remember
that "m" refers to the match object while they read the
next couple of lines. IMO, using a longer name would serve
no purpose and would just clutter things up.

-- 
Greg



More information about the Python-ideas mailing list