Title: csvwriter.writerow()'s return type is undocumented
Type: enhancement Stage:
Components: Documentation, Library (Lib) Versions: Python 3.8, Python 3.7, Python 3.6
Status: open Resolution:
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, nchammas, remi.lapeyre, xtreak
Priority: normal Keywords:

Created on 2018-09-17 17:14 by nchammas, last changed 2019-03-13 17:09 by nchammas.

Messages (5)
msg325557 - (view) Author: Nicholas Chammas (nchammas) * Date: 2018-09-17 17:14
It _looks_ like csvwriter.writerow() returns the number of bytes (or is it characters?) written. However, there is no documentation of this:

Is this behavior part of the method's "contract"? And if so, shouldn't we document it?

The same goes for csvwriter.writerows().
msg325559 - (view) Author: Nicholas Chammas (nchammas) * Date: 2018-09-17 17:20
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
msg337776 - (view) Author: Rémi Lapeyre (remi.lapeyre) * Date: 2019-03-12 16:43
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?
msg337840 - (view) Author: Rémi Lapeyre (remi.lapeyre) * Date: 2019-03-13 10:11
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

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?
msg337866 - (view) Author: Nicholas Chammas (nchammas) * Date: 2019-03-13 17:09
Nope, go ahead.
Date User Action Args
2019-03-13 17:09:31nchammassetmessages: + msg337866
2019-03-13 10:11:40remi.lapeyresetmessages: + msg337840
2019-03-12 16:43:29remi.lapeyresetnosy: + remi.lapeyre
messages: + msg337776
2018-09-17 18:33:27xtreaksetnosy: + xtreak
2018-09-17 17:20:27nchammassetmessages: + msg325559
2018-09-17 17:14:05nchammascreate