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

Neil Girdhar mistersheik at gmail.com
Sun May 13 15:13:24 EDT 2018

```On Sun, May 13, 2018 at 2:54 PM Matt Arcidy <marcidy at gmail.com> wrote:

>
>
> On Sun, May 13, 2018, 11:28 Brendan Barnwell <brenbarn at brenbarn.net>
> wrote:
>
>> On 2018-05-13 04:23, Steven D'Aprano wrote:
>> > In my experience mathematicians put the given *before* the statement:
>> >
>> >     Given a, b, c three sides of a triangle, then
>> >
>> >         Area = sqrt(s*(s-a)*(s-b)*(s-c))
>> >
>> >     where s = (a + b + c)/2 is the semi-perimeter of the triangle.
>> >
>> > For the record, that is almost exactly what I wrote for a student
>> > earlier today, and its not just me, it is very similar to the wording
>> > used on both Wolfram Mathworld and Wikipedia's pages on Heron's Formula.
>> >
>> > http://mathworld.wolfram.com/HeronsFormula.html
>> >
>> > https://en.wikipedia.org/wiki/Heron%27s_formula
>> >
>> >
>> > Putting "given" after the expression is backwards.
>>
>
I usually read the vertical bar "given" in

set-builder notation:  {x | 10 < x < 100, x is prime}

Conditional probabilities, expectations, entropy, etc.: P(X | Y), E(X| Y),
H(X | Y),

And, the so-called "evaluation bar":
https://math.stackexchange.com/questions/52651/what-is-the-name-of-the-vertical-bar-in-x21-vert-x-4-or-left-left

In words, I agree that where is probably better in text because writing
"given the gravitational constant G" puts the subject last, unlike "where G
is the gravitational constant".  However, the given proposal for Python is
putting the subject first: "given x = y".

>>         Yes, but that's because we're ruling out the use of "where".  At
>> this
>> point I would be fine with "snicklefritz" as the keyword.  The point is
>> that I want to put SOMETHING after the expression, and this is not at
>> all unusual.  See for instance Wikipedia pages on the Reimann zeta
>> function
>> (https://en.wikipedia.org/wiki/Riemann_zeta_function#Definition),
>> gravitation equation
>> (https://en.wikipedia.org/wiki/Gravity#Newton%27s_theory_of_gravitation),
>> and
>> compound interest
>> (
>> https://en.wikipedia.org/wiki/Compound_interest#Mathematics_of_interest_rate_on_loans).
>>
>>   If we have to use the word "given" even though the word mathematicians
>> would use in that position is "where", that's not such a big deal.
>>
>
> it is a big deal.  postfix requires more cognitive load, we will have no
> idea up front what's going on except for trivial exames.  more givens, more
>
> if you think spending that is fine for you, I can't argue, but to say it
> doesn't matter isn't correct.
>
> 2.exames which get far worse for complex cases.  left for the for can be
> as complex.as.you wish.
> 1:
> [ x + y for t in range(10)  ... ]
>
> 2:
> x = 10
> y = 20
> [ x + y for t in range(10) ...]
>
> up till you read ... you have no idea there even will be a substitution.
> The lower is even worse, you think you know, but then have to redo the
> whole problem with new information.
>
> also :
> mathematicians don't just put the _word_ "given", they put givens, things
> that are known or assumed to be true.  Axioms and definitions, where
> definitions assign names to values.  This is for formal arguements.
> reassigning values is handled in post fix occasionally once it is clear
> what x and y are.  but that's not what we are talking about if the name
>

Most (if not all) uses of the vertical are read as "given" and they all put
the givens to the right of it.

>
> again, you want to use given, that's fine, but the math argument is wrong,
> as is the "it doesn't matter" argument, assuming the current neurological
> model for working memory continues to hold.
>
>  Maybe the difference is small, especially after familiarity sets in, but
> that doesn't mean the difference in load isn't there.  it will only
> increase for more complex statements with more givens.
>
>>
>> --
>> Brendan Barnwell
>> 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/
>>
> --
>
> ---
> You received this message because you are subscribed to a topic in the
> To unsubscribe from this topic, visit
> To unsubscribe from this group and all its topics, send an email to
> For more options, visit https://groups.google.com/d/optout.
> _______________________________________________
> 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/
>
> --
>
> ---
> You received this message because you are subscribed to a topic in the