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

Matt Arcidy marcidy at gmail.com
Fri May 11 14:52:02 EDT 2018

Apology for top post, but this is a general statement about Readability and
not a response to an individual.

it would be nice to list the objective parts separate from the "argument"
(i.e. debate, not fight), perhaps list them then make a case for which
metric is a more important, and which values produce better results.

Key strokes, keyboard location, location of information vs where it is
used, cognitive load (objective barring neuroscience changes) are all
objective points (along with many other points raised).

"Better" will be decided by Guido I guess, but listing objective points
with explanatory examples gives a basis for that discussion.

Legibility, for example, is not objective at all, it has nothing to do with
syntax.  This covers fonts, colors, monitors, lighting, chairs, lunch,
etc.  None of this is relevent to the symbols or their ordering in a file
we all must read.

Teachability likewise.  My opinion here is learnability is far more
important anyways, I am 90% self taught going back 25 years, but this is
equally unquantifiable.  Perhaps just trust students to learn as an author
must trust a reader.

Of course, let it not be lost that determining teachability and
learnability for something which doesn't even exist yet is quite

Any quantification will give more information than only naked impassioned
pleas to Readability.

Note Tim came up with a real metric:
2 * count(":=")/len(statement).
It's objective.  it's just unclear if a higher score is better or worse.
However, one could say "a Tim of .3 is considered too high" as a guideline.

Perhaps coders find these opportunities to express feelings and opinion
cathartic after speaking to the most pedantic creature on Earth
(compilier/computer) but I think exercising the high skill level available
here to dissect and find objective statements is a worthy puzzle.

On Fri, May 11, 2018, 11:14 Brendan Barnwell <brenbarn at brenbarn.net> wrote:

> On 2018-05-11 11:08, Brendan Barnwell wrote:
> > . . . and it's true the latter is a bit more verbose in that case for
> > little extra benefit.  But when the locally-defined value is used within
> > a more complicated expression (like the quadratic formula example), I
> > think readability goes down significantly.  To appease Tim, instead of
> > using the quadratic formula, though, I will use a more realistic example
> > that comes up fairly often for me: wanting to do some kind of
> > normalization on a piece of data for a comparison, while keeping the
> > unnormalized data for use within the block:
> >
> >       if some_condition and (stuff:=
> > get_user_input()).lower().strip().replace('-', ''):
> >
> > versus
> >
> >       if some_condition and stuff.lower().strip().replace('-', '') given
> > stuff = get_user_input():
>         Ironically I weakened my argument by forgetting to finish my
> expression
> there.  I intended that chain of method calls to be used in a comparison
> to make the surrounding expression more complex.  So revise the above to
>         if some_condition and (stuff :=
> get_user_input()).lower().strip().replace('-', '') == existing_value:
> versus
>         if some_condition and stuff.lower().strip().replace('-', '') ==
> existing_value given stuff = get_user_input():
> --
> Brendan Barnwell
> "Do not follow where the path may lead.  Go, instead, where there is no
> path, and leave a trail."
>     --author unknown
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180511/dd0fcbab/attachment.html>

More information about the Python-ideas mailing list