Re:Anti-Patterns in Python Programming
by a3n on Wednesday July 09, 2014 @10:37AM
(#8009814)
Don't know if this is why, but the list comprehension takes an expression at the "foo(word)" location, and is therefore more general than map, which requires a function. The comprehension in that case is simpler.
I like looking at the list comprehension better. The use of lambda looks forced in this case. I also imagine there's a penalty for calling the (anonymous) function in map.
[ Parent
| on HN ]
Re:Anti-Patterns in Python Programming
by icebraining on Wednesday July 09, 2014 @07:11PM
(#8012727)
In that case I'd use
map(itemgetter(1), words)Instead of my map example, or instead of a list comprehension in general?
Re:Anti-Patterns in Python Programming
by icebraining on Thursday July 10, 2014 @04:21AM
(#8014148)
Instead of a list comprehension equivalent to your example.