On Thu, May 24, 2018 at 12:04 PM Robert Vanden Eynde <robertv...@gmail.com> wrote:
> This idea was mentioned (by me) at a time yes, but wasn't written in the document. Can you point me to a specific post? There were so may that I must have missed that one. > I think one of the thing was that it would make the grammar non LL1 because when seeing the token "for" in a list comprehension it wouldn't know in advance if it's the loop or the assignment. I don't see how that can be a problem. From the grammar point of view, "for" in "for var = <expr>" may still be seen as introducing a "loop", but when "=" is seen in place of "in", the compiler will resize that the "loop" is one a single value and emit efficient code for it. At the AST level, "for var = <expr>" will look exactly the same as "for var in <expr>" only with an "=" instead of "in". > And also, it might confuse people because 'for' is for iteration. I think I addressed this in my previous post. Yes, for people with a C/C++ background, "for" may be too strongly associated with loops, but in mathematical sense, it seems clear that "for var in a set" means iteration over a set, while "for var = expression" means binding to a single value.
_______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/