I\'m trying to use map in Python3. Here\'s some code I\'m using:
import csv
data = [
[1],
[2],
[3]
]
with open(\"output.csv\", \"w
You can set up a zero length deque to do this:
with open("output.csv", "w") as f:
writer = csv.writer(f)
collections.deque(map(writer.writerow, data),0)
This is the same way that itertools.consume(iterator, None) recipe works. It functionally will exhaust the iterator without building the list.
You can also just use the consume recipe from itertools.
But a loop is more readable and Pythonic to me, but YMMV.