Guido van Rossum wrote: > > > I would also like to volunteer to repeat the "simultaneous loop" syntax > > experiment with list comprehensions, i.e. see whether what's being > > proposed lines up with people's pre-existing intuitions. > > Please do! > > Though I have no doubt of the outcome: > > [x+y for x in [10, 20, 30] for y in [1, 2, 3]] > > will be almost universally understood to mean > > [11, 12, 13, 21, 22, 23, 31, 32, 33]. Just a note about the syntax: why does the above have the expression and the "for" notation reversed ? Wouldn't it make much more sense to write something more lambda function like, e.g. [for (x,y) in zip([10,20,30], [1,2,3]): x+y] or [for x in range(100): x*2] ? I believe the above would cause much less confusion since it resembles standard Python "for" loop notation (making it intuitive for Python programmers) and is in syntax very similar to what "lambda" uses: lambda <vars>: <evaluated expr> List comprehension would then become something like: [for <vars> in <expr>: <evaluated expr>] -- Marc-Andre Lemburg ______________________________________________________________________ Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4