Re:Origins of Python's “Functional” Features (2009)
by clusmore on Monday January 09, 2017 @01:07AM
(#13354361)
Well, for one I believe they pre-date comprehensions. Having them as functions is also occasionally useful for partial application, e.g.
[ Parent
| on HN ]
Re:Origins of Python's “Functional” Features (2009)
by m_mueller on Monday January 09, 2017 @01:20AM
(#13354423)
I can see it together with partial, yes, that's when it can become a bit cleaner. Another reason why I use map is when I want to use multiprocessing or multithreading (with IO heavy functions). But on a fine grained level of code I find it really hurts readability compared to comprehensions.
Re:Origins of Python's “Functional” Features (2009)
by EvilTerran on Monday January 09, 2017 @07:39AM
(#13355895)
Or this:
def to_strings(seq):
return map(str, seq)
Generally, when the operation I'm applying to each element happens to already be a named function, I find "map(f, seq)" preferable to "(f(x) for x in seq)".