Greg Ewing <greg@cosc.canterbury.ac.nz>: > Two reasons why list comprehensions fit better in Python > than the equivalent map/filter/lambda constructs: > > 1) Scoping. The expressions in the LC have direct access to the > enclosing scope, which is not true of lambdas in Python. This is a bug in lambdas, not a feature of syntax. > 2) Efficiency. An LC with if-clauses which weed out many potential > list elements can be much more efficient than the equivalent > filter operation, which must build the whole list first and > then remove unwanted items. A better argument. To refute it, I'd need to open a big can of worms labeled "lazy evaluation". -- <a href="http://www.tuxedo.org/~esr">Eric S. Raymond</a> Freedom, morality, and the human dignity of the individual consists precisely in this; that he does good not because he is forced to do so, but because he freely conceives it, wants it, and loves it. -- Mikhail Bakunin
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