This question might be sound subjective, but as "the Zen" says, there is (nearly always) one way to preferred, it shouldn't be subjective at the end.
What way is the better one?
[i.something() for i in l]
map(operator.methodcaller('something'), l)
map(lambda x: x.something(), l)
(1) is (IMO) very clear, but in many answers, map()
is used. And if we do so, there is nearly equal readability between (2) and (3) (IMO, at least).
The same counts for many other tasks, but I have chosen this one, as it can stand for all of similiar ones.
Both are clear arguments for
[i.something() for i in l]
.This assumes that
.something()
doesn't mutatei
, and that you're on Python 2.