Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

But you only ever need to unwrap one sum(). And with sequence comprehensions, what you get instead is sum(... for ... if ... for ... if ...) - I don't think that's improved by rewriting it as (...).sum().


There's a not unreasonable position implicit in Python's way that the "most significant" operation should be most visible.

The problem with filter chaining is the final assignment and the actual value are separated by the rest of the chain.

i.e. x = strList.filter(parseInt).sum() doesn't tell me what type x is till I read the whole line.

Whereas:

x = sum( parseInt(v) for v in strList ) tells me as quickly as possible that I'm dealing with a single value output that will be a sum.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: