[issue23171] csv.writer.writerow() does not accept generator (must be coerced to list)
R. David Murray added the comment: Looks like Serhiy forgot to close this, so closing it. -- assignee: serhiy.storchaka - ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23171 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23171] csv.writer.writerow() does not accept generator (must be coerced to list)
R. David Murray added the comment: No, I just had a stale tab :( :( -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23171 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23171] csv.writer.writerow() does not accept generator (must be coerced to list)
Roundup Robot added the comment: New changeset cf5b62036445 by Serhiy Storchaka in branch 'default': Issue #23171: csv.Writer.writerow() now supports arbitrary iterables. https://hg.python.org/cpython/rev/cf5b62036445 -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23171 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23171] csv.writer.writerow() does not accept generator (must be coerced to list)
Changes by Serhiy Storchaka storch...@gmail.com: -- resolution: - fixed stage: patch review - resolved status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23171 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23171] csv.writer.writerow() does not accept generator (must be coerced to list)
Martin Panter added the comment: Left a question about handling of the unquoted empty field exception on Rietveld. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23171 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23171] csv.writer.writerow() does not accept generator (must be coerced to list)
Changes by Serhiy Storchaka storch...@gmail.com: -- assignee: - serhiy.storchaka ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23171 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23171] csv.writer.writerow() does not accept generator (must be coerced to list)
Changes by Martin Panter vadmium...@gmail.com: -- nosy: +vadmium ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23171 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23171] csv.writer.writerow() does not accept generator (must be coerced to list)
Changes by Éric Araujo mer...@netwok.org: -- nosy: +eric.araujo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23171 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23171] csv.writer.writerow() does not accept generator (must be coerced to list)
Serhiy Storchaka added the comment: The docs mention that row should be a sequence, so there is no a bug. Here is a patch which makes writerow() accept an iterable without converting it to a list. It also adds tests for few corner cases and fixes the docs. -- nosy: +serhiy.storchaka stage: needs patch - patch review Added file: http://bugs.python.org/file37612/csv_writerow_iterable.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23171 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23171] csv.writer.writerow() does not accept generator (must be coerced to list)
R. David Murray added the comment: Hmm. That could be an issue. If someone passes a generator they will generally expect it to be consumed as a generator, not turned into a list implicitly. So it may be better to turn this into a doc bug and require the explicit list call :(. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23171 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23171] csv.writer.writerow() does not accept generator (must be coerced to list)
New submission from Jon Dufresne: 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) --- -- components: Library (Lib) messages: 233470 nosy: jdufresne priority: normal severity: normal status: open title: csv.writer.writerow() does not accept generator (must be coerced to list) type: behavior versions: Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23171 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23171] csv.writer.writerow() does not accept generator (must be coerced to list)
Jon Dufresne added the comment: I have created an initial patch such that writerow() now allows generators. I have also added a unit test to demonstrate the fix. The code now coerces iterators (and generators) to a list, then operates on the result. I would have preferred to simply iterate over the argument, however, there is a special case where the length of the argument is exactly 1. So coercing to a list makes checking the length simpler. All feedback welcome. -- keywords: +patch Added file: http://bugs.python.org/file37609/csv-gen.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23171 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23171] csv.writer.writerow() does not accept generator (must be coerced to list)
R. David Murray added the comment: This seems like a sensible enhancement request to me. It is possible it could even be considered a bug, the docs aren't exactly clear on what 'row' is expected to be. -- keywords: +easy nosy: +r.david.murray stage: - needs patch type: behavior - enhancement versions: +Python 3.5 -Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23171 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com