Commit 3d7e95b6 authored by Skip Montanaro's avatar Skip Montanaro

bring description of optional and keyword args for DictReader and DictWriter

classes into line with the actual code.  I didn't see any obvious examples
of latex formatting for *args and **kwds so I just guessed.
parent 49996e49
...@@ -122,7 +122,7 @@ The \module{csv} module defines the following classes: ...@@ -122,7 +122,7 @@ The \module{csv} module defines the following classes:
restkey=\constant{None}\optional{, restkey=\constant{None}\optional{,
restval=\constant{None}\optional{, restval=\constant{None}\optional{,
dialect=\code{'excel'}\optional{, dialect=\code{'excel'}\optional{,
fmtparam}}}}}} *args, **kwds}}}}}}
Create an object which operates like a regular reader but maps the Create an object which operates like a regular reader but maps the
information read into a dict whose keys are given by the optional information read into a dict whose keys are given by the optional
{} \var{fieldnames} {} \var{fieldnames}
...@@ -133,15 +133,16 @@ the value of \var{restval} will be used as the default value. If the row ...@@ -133,15 +133,16 @@ the value of \var{restval} will be used as the default value. If the row
read has more fields than the fieldnames sequence, the remaining data is read has more fields than the fieldnames sequence, the remaining data is
added as a sequence keyed by the value of \var{restkey}. If the row read added as a sequence keyed by the value of \var{restkey}. If the row read
has fewer fields than the fieldnames sequence, the remaining keys take the has fewer fields than the fieldnames sequence, the remaining keys take the
value of the optional \var{restval} parameter. All other parameters are value of the optional \var{restval} parameter. Any other optional or
interpreted as for \class{reader} objects. keyword arguments are passed to the underlying \class{reader} instance.
\end{classdesc} \end{classdesc}
\begin{classdesc}{DictWriter}{csvfile, fieldnames\optional{, \begin{classdesc}{DictWriter}{csvfile, fieldnames\optional{,
restval=""\optional{, restval=""\optional{,
extrasaction=\code{'raise'}\optional{, extrasaction=\code{'raise'}\optional{,
dialect=\code{'excel'}\optional{, fmtparam}}}}} dialect=\code{'excel'}\optional{,
*args, **kwds}}}}}
Create an object which operates like a regular writer but maps dictionaries Create an object which operates like a regular writer but maps dictionaries
onto output rows. The \var{fieldnames} parameter identifies the order in onto output rows. The \var{fieldnames} parameter identifies the order in
which values in the dictionary passed to the \method{writerow()} method are which values in the dictionary passed to the \method{writerow()} method are
...@@ -151,8 +152,9 @@ specifies the value to be written if the dictionary is missing a key in ...@@ -151,8 +152,9 @@ specifies the value to be written if the dictionary is missing a key in
method contains a key not found in \var{fieldnames}, the optional method contains a key not found in \var{fieldnames}, the optional
\var{extrasaction} parameter indicates what action to take. If it is set \var{extrasaction} parameter indicates what action to take. If it is set
to \code{'raise'} a \exception{ValueError} is raised. If it is set to to \code{'raise'} a \exception{ValueError} is raised. If it is set to
\code{'ignore'}, extra values in the dictionary are ignored. All other \code{'ignore'}, extra values in the dictionary are ignored. Any other
parameters are interpreted as for \class{writer} objects. optional or keyword arguments are passed to the underlying \class{writer}
instance.
Note that unlike the \class{DictReader} class, the \var{fieldnames} Note that unlike the \class{DictReader} class, the \var{fieldnames}
parameter of the \class{DictWriter} is not optional. Since Python's parameter of the \class{DictWriter} is not optional. Since Python's
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment