Message233470
| Author |
jdufresne |
| Recipients |
jdufresne |
| Date |
2015年01月05日.17:31:42 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1420479102.66.0.846752030326.issue23171@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
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)
--- |
|
History
|
|---|
| 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 |
|