"Oliver Korpilla" <korpo at 01019freenet.de> wrote in message news:3AE19990.B41D5C9D at 01019freenet.de... > Good to see I always do learn something new from this newsgroup! > > Actually I was relying on book knowledge about Python, a book that > especially mentions FP tools in Python but NOT list comprehension at all > (never saw it in my books). > > Is it a new feature ? (version introduced ?) It's relatively new, I believe it was introduced in 1.6 in the summer of the year 2000 (or was it in 2.0? hard to recall, since 1.6 final and the first 2.0 alpha came the same _day_). > Since I didn't see it on list manipulation either! > > Where do I get more info about it ? (part of the tutorial) List comprehension is documented in the standard Python docs, but the language manual isn't meant for easy reading. http://www.python.org/doc/current/ref/lists.html, anyway. > Besides: > If inlining functions does the trick for sharing local variables into > local function definitions (without being parameters), then filter f xs > could do the trick as well as the list comprehension does.. is this > correct ? Sorry, I'm not sure I understand your sentence. Nested scoping, if that's what you mean, is in Python 2.1 (experimental, yet, you have to explicitly enable it; will be standard in 2.2). Anyway, in my opinion the examples I give DO show that 'filter does the trick as well as list comprehension', and that the only extra that nested scoping will give you for this qsort program is more choice in what you choose to name or not name. In Haskell, too, you could use filters instead of the two list comprehensions, and again you get choices regarding naming or not naming things. Not quite the same choices as Python -- referring to head and tail of list is vastly easier WITH names in Haskell, while in Python the [0] indexing and [1:] slicing mean that naming them is strictly a stylistic choice; on the other hand, a local function in Python can be unnamed [lambda] only _with_ serious constraints on what it can do, you need to name it if you want full generality. Six of one, half a dozen of the other. Plus, I wouldn't obsess about what needs to be given a name or may be given a name and what may or must be left unnamed -- that doesn't seem the crux of the matter. Alex
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