Message233470
The csv.writer.writerow() does not accept a generator as input. I find this counter-intuitive and against the spirit of similar APIs. If the generator is coerced to a list, everything works as expected. See the following test script which fails on the line "w.writerow(g)". In my opinion, this line should work identically to the line "w.writerow(list(g))".
---
import csv
f = open('foo.csv', 'w')
w = csv.writer(f)
g = (i for i in ['a', 'b', 'c'])
w.writerow(list(g))
g = (i for i in ['a', 'b', 'c'])
w.writerow(g)
--- |
|
Date |
User |
Action |
Args |
2015-01-05 17:31:42 | jdufresne | set | recipients:
+ jdufresne |
2015-01-05 17:31:42 | jdufresne | set | messageid: <1420479102.66.0.846752030326.issue23171@psf.upfronthosting.co.za> |
2015-01-05 17:31:42 | jdufresne | link | issue23171 messages |
2015-01-05 17:31:42 | jdufresne | create | |
|