collection = []
for i in data:
collection.append(fn(i))
Why not just [fn(i) for i in data] ? collection = []
for i in data:
collection.append(fn(i))
Why not just [fn(i) for i in data] ?However, in this particular case, IMO, it would make things worse because I would have to write a multi-line list comprehension. Multi-line list comprehensions have bad readability. The object literal is too big to be included in list comprehension.
I could move commit->object conversion to a function, but then I would have used map. And it would have created one more indirection.
The current state is my deliberate choice.
map(fn, data)
?List comprehensions are the very recommended strategy for constructing python lists, not to mention they're simply a fantastic language feature. Very direct, readable, and hard to get wrong.
Python loses out a lot on it's functional sorts of functions (filter, map) because you can't use method chaining on a list for them, imo