[issue34713] csvwriter.writerow()'s return type is undocumented

New submission from Nicholas Chammas <nicholas.chammas@gmail.com>: It _looks_ like csvwriter.writerow() returns the number of bytes (or is it characters?) written. However, there is no documentation of this: https://docs.python.org/3.7/library/csv.html#csv.csvwriter.writerow Is this behavior part of the method's "contract"? And if so, shouldn't we document it? The same goes for csvwriter.writerows(). ---------- assignee: docs@python components: Documentation, Library (Lib) messages: 325557 nosy: docs@python, nchammas priority: normal severity: normal status: open title: csvwriter.writerow()'s return type is undocumented type: enhancement versions: Python 3.6, Python 3.7, Python 3.8 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue34713> _______________________________________

Nicholas Chammas <nicholas.chammas@gmail.com> added the comment: Looks like it's bytes written, not characters: ```
import csv with open('test.csv', 'w', newline='') as csv_file: ... csv_writer = csv.writer( ... csv_file, ... dialect='unix', ... ) ... csv_writer.writerow('야 너') # 3 characters ... 12
----------
_______________________________________
Python tracker <report@bugs.python.org>
<https://bugs.python.org/issue34713>
_______________________________________

Change by Karthikeyan Singaravelan <tir.karthi@gmail.com>: ---------- nosy: +xtreak _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue34713> _______________________________________

Rémi Lapeyre <remi.lapeyre@henki.fr> added the comment: csvwriter.writerows() does not return anything. The return value of csv.writecsv() is the return value of the write() method of the file object given as parameter in csv.writer(). I'm not sure it's safe to document it, should we return None instead? ---------- nosy: +remi.lapeyre _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue34713> _______________________________________

Rémi Lapeyre <remi.lapeyre@henki.fr> added the comment: Issue #27497 is related, it adds documentation a return value and documentation to csv.DictWriter.writeheader which uses writerow internally. In the discussion, @lsowen found code that uses it at https://docs.djangoproject.com/en/1.9/howto/outputting-csv/#streaming-large-.... Given that this behavior has been added to csv.DictWriter.writeheader it makes sense to document csv.Writer.writerow. Do you want to post a pull request? ---------- _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue34713> _______________________________________

Nicholas Chammas <nicholas.chammas@gmail.com> added the comment: Nope, go ahead. ---------- _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue34713> _______________________________________
participants (3)
-
Karthikeyan Singaravelan
-
Nicholas Chammas
-
Rémi Lapeyre