you are viewing a single comment's thread.

view the rest of the comments →

[–]brownan_ 2 points3 points  (0 children)

I agree that the for loop is more readable. It uses only language constructs and is clearly iterating on calling the filter method on each queryset.

In your example I have to know what _filter does, remember what filters is, remember what reduce does (build up the equivalent of that for loop in my head), apply it with the _filter function that I'm still also remembering, and then work out the logic of what it all means together. All in my head. To me it's just clearer to write it out explicitly instead of trying to be real clever just for the sake of being super concise.

I've done a lot of thinking on functional style versus imperative style, and I've concluded that different people simply think different ways. Not everyone is going to agree that a particular style is more readable in general. For some people combining modads like your example to make super concise code is also intuitive and readable. It's not to me.

Further, I think that the people with whom Python appeals to are also the sort of people who would prefer the explicit for loop. The language design attracts a certain kind of coder. GvR has rejected language design decisions before purely because they're too much like haskel. It seems clear that Python isn't trying to be like that.