Using map
for its side-effects (eg function call) when you're not interested in returned values is undesirable even in Python2.x. If the function returns None
, but repeats a million times - you'd be building a list of a million None
s just to discard it. The correct way is to either use a for-loop and call:
for row in data:
writer.writerow(row)
or as the csv
module allows, use:
writer.writerows(data)
If for some reason you really, really wanted to use map
, then you can use the consume
recipe from itertools and generate a zero length deque, eg:
from collections import deque
deque(map(writer.writerow, data), maxlen=0)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…