Re:Anti-Patterns in Python Programming
by RHSeeger on Wednesday July 09, 2014 @12:28PM
(#8010506)
Admittedly, my thought would be to chain the calls, not nest them:
That being said, my Python is limited and I don't know it filter/map are available as methods of a list. At the end of the day, there are cases where list comprehensions are much cleaner/understandable... and cases where the reverse is true.
[ Parent
| on HN ]
> I don't know it filter/map are available as methods of a list.
They're not. Which is a shame in my opinion, because as you've written it you can clearly read the operations in the order they happen, ie. filter followed by map. Instead, you do have to do the second line of what blossoms wrote above.
And I don't think it's possible to write a list comprehension that reads in execution order, either :(