Fredrik Lundh wrote: > > SETL sure has a pythonic feel... > > with a few improvements, of course (like the [start next end] > range literals... too late to fix that in python, I suppose...) > > and personally, I prefer their "tuple former" syntax over the the > current PEP202 proposal: > > [expression : iterator] > > [n : n in [1:100]] > [(x**2, x) : x in [1:5]] > [a : a in y if a > 5] > > (all examples are slightly pythonified; most notably, they > use "|" or "st" (such that) instead of "if") > > the expression can be omitted if it's the same thing as the > loop variable, *and* there's at least one "if" clause: > > [a in y if a > 5] > > also note that their "for-in" statement can take qualifiers: > > for a in y if a > 5: > ... > > is there any special reason why we cannot use colon instead > of "for"? For mathematicians the [<expr> : <condition>] or [<expr> | <condition>] looks natural since it's their every day style of writing sets, but I doubt that CP4E users get the grasp of this. Anyway, whatever syntax you choose, please make sure that the <expr> and the <condition> parts are very well visibily separated. [<expr> for <vars> in <list>] doesn't fall in that category, IMHO. Hehe, this is starting to get the feel of SQL with their horrible SELECT syntax: SELECT <vars> FROM <list> WHERE <condition> ORDER BY <vars> etc. pp. -- 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