Hacker News new | ask | show | jobs
by andreasvc 4985 days 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.

1 comments

In 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]