2 ms·
Yeah I know. Maybe "force" is not the right word ... probably "discourage"? Actually only one line of code is enough for each of map/filter: def map(fn, s
by riobard 17y ago
Yeah I know. Maybe "force" is not the right word ... probably "discourage"?
Actually only one line of code is enough for each of map/filter:
def map(fn, seq): return [fn(each) for each in seq]
def filter(cond: seq): return [each for each in seq if cond(each)]
But seriously, what do you really gain by removing these two? Isn't that too ideological? I don't really see how un-Pythonic it would be to use map/filter instead of list comprehensions. The problem is BDFL's attitude seems to drive many FP-ers away, like the guy in the original post.
- kingkilr 17y agoThey ultimately weren't removed. reduce was removed from the builtins, but it's still just one import away. From itertools import reduce.