4 ms·
On the last point, a list comprehension is just a much a functional programming idiom--Python got them from Haskell! I use both in my code, whichever is shortes
by andreasvc 14y ago
On the last point, a list comprehension is just a much a functional programming idiom--Python got them from Haskell! I use both in my code, whichever is shortest.
PS: map returns a list, no need to call list() on it.
- walrus 14y agoIn Python 3, map returns a iterator, not a list: In [1]: sq = lambda x: x * x In [2]: map(sq, [1,2,3,4]) Out[2]: <builtins.map at 0x2135050> In [3]: list(_) Out[3]: [1, 4, 9, 16]