Peter Schneider-Kamp wrote: > > > Would [x,y , for x in list1, if x > 1, if y > 2, for y in list2] > be allowed? In other words: Should there be some rules of ordering? Would this syntax make the answer clearer: [for x in list1: if x > 1: if y > 2: for y in list2: x,y] I don't think that makes sense unless y is externally bound. > Would the following be allowed (and desirable)? > y = 3 > [ x + y , for x in [1, 2, 3], if x > 1] > producing [5, 6] y = 3 [for x in [1, 2, 3]: if x > 1: x + y] Sure, getting around Python's name binding "issues" is one of the (side) benefits of list comprehensions. -- Paul Prescod - Not encumbered by corporate consensus Simplicity does not precede complexity, but follows it. - http://www.cs.yale.edu/~perlis-alan/quotes.html
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