It was a long time ago I couldn't easily find the post but that's alright, you refreshed the idea :)
Let's see what others think of for x = I also remembered some languages (like lua) use for x = range (5) interchangeably with for x in range (5) and guido said it will never make such a thing, for .. in being the iteration. Le jeu. 24 mai 2018 à 18:22, Alexander Belopolsky < alexander.belopol...@gmail.com> a écrit : > > > 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/