Re:Ask HN: Good Python codebases to read?
by aaronchall on Thursday July 16, 2015 @11:23PM
(#9901137)
OK so let's talk about that, which is more readable?:
iterable = xrange(10)
ge = (x*x for x in iterable if not x % 2)
mf = map(lambda x: x*x, filter(lambda x: not x % 2, iterable))
Assume imap and ifilter from itertools or Python 3 (with range) for equivalence. I'm betting if we ask any person new to Python and new to programming, they'd think the former much more readable than the latter. Yes, we left it in the language for you cranks who think map, filter, and lambda are way better, but it's functionally no different.
I would say that is debatable. Coming from an FP background, I use map, filter and lambdas nearly all of the time because I find it more readable and can easily reason about the code. I have seen some two line list comprehensions and they are far harder for me to read and understand.