mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-27497: Add return value to csv.DictWriter.writeheader (GH-12306)
csv.DictWriter.writeheader() now returns the return value of the underlying csv.Writer.writerow() method. Patch contributed by Ashish Nitin Patil.
This commit is contained in:
parent
d237b3f0f6
commit
fce5ff1e18
4 changed files with 18 additions and 3 deletions
|
@ -443,7 +443,8 @@ read CSV files (assuming they support complex numbers at all).
|
|||
.. method:: csvwriter.writerow(row)
|
||||
|
||||
Write the *row* parameter to the writer's file object, formatted according to
|
||||
the current dialect.
|
||||
the current dialect. Return the return value of the call to the *write* method
|
||||
of the underlying file object.
|
||||
|
||||
.. versionchanged:: 3.5
|
||||
Added support of arbitrary iterables.
|
||||
|
@ -467,9 +468,14 @@ DictWriter objects have the following public method:
|
|||
|
||||
.. method:: DictWriter.writeheader()
|
||||
|
||||
Write a row with the field names (as specified in the constructor).
|
||||
Write a row with the field names (as specified in the constructor) to
|
||||
the writer's file object, formatted according to the current dialect. Return
|
||||
the return value of the :meth:`csvwriter.writerow` call used internally.
|
||||
|
||||
.. versionadded:: 3.2
|
||||
.. versionchanged:: 3.8
|
||||
:meth:`writeheader` now also returns the value returned by
|
||||
the :meth:`csvwriter.writerow` method it uses internally.
|
||||
|
||||
|
||||
.. _csv-examples:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue