[Python-ideas] Reuse "for" to express "given"

Matt Arcidy marcidy at gmail.com
Thu May 24 16:59:02 EDT 2018

On Thu, May 24, 2018, 11:47 Alexander Belopolsky <
alexander.belopolsky at gmail.com> wrote:

> > But I do have a mathematics background, and I don't remember ever seeing
> > "for x = value" used in the sense you mean.
> That's so because in mathematics, "for" is spelled ":" as in
>  {2*a* : *a*∈*Z*}
> If you can read the above, you should not have trouble reading
>  {2*a* + *b* : *a*∈*Z *: *b = *1}

Inverted "A" is "for all", and colon means "such that".  It may be
acceptable somewhere to use a colon as you do, but the lone colon
unambiguously is "such that" when constructing sets.  I never once saw
colon used this way, and would be interested to see it in a proper math
paper to correct my world view.

"for" only reads as "such that" as:
"A such that x = 1"
"A, for x = 1" which sounds a bit Shakespearian and is definitely not

standard math:
"2a plus b for all integers such that b is 1."
"2a plus b for each integer such that b is 1"

using "for" as ":":
"2a plus b for a in integers for b in 1"
"2a plus b for a eauals integers for b eauals 1"
"2a plus b for all a in integers for all b in 1"

Understandable, but I would get zero point on my homework for those, they
are correct.

In the context of math in general, ":=" makes more sense, and is actual
math notation for assignment:


ignoring math:

I'm kind of fine with nudging the meaning of "for" as you describe to be
assignment, it's close enough, such that it's not a long leap.  I think
this point is the best case for "for",  but I don't think being the only
language to do this is great, and I usually don't care about language
similarities.   I lack breadth, however, so please correct me here.

However, I cannot say this is superior to ":=" based on the same logic, as
":=" achieves the same ends with less semantic confusion, typing, and uses
earlier indication of assignment.

And please note that making "for" ambiguous when there is already the
ambiguity in post fix notation makes the spelling less desirable to me. In
this spelling, for one assignment, there are two ambiguities that must be
resolved: the assigned name and the meaning of "for", though the latter is
cleared up quickly.  This small ambiguity is still there and I don't see a
reason to introduce it.


> _______________________________________________
> 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/20180524/af4aabf9/attachment-0001.html>

More information about the Python-ideas mailing list