Skip to content

Commit e839679

Browse files
[3.15] gh-80678: Document the preferred attribute of csv.Sniffer (GH-155068) (#155679)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
1 parent dd4bd4c commit e839679

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

Doc/library/csv.rst

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,8 @@ The :mod:`!csv` module defines the following classes:
314314

315315
If several delimiters fit the sample equally well ---
316316
for example if both ``','`` and ``';'`` split every row consistently ---
317-
the delimiters ``','``, ``'\t'``, ``';'``, ``' '`` and ``':'``
318-
are preferred, in this order,
317+
the delimiters listed in the :attr:`~Sniffer.preferred` attribute
318+
are preferred, in that order,
319319
no matter how many times each of them occurs.
320320

321321
.. method:: has_header(sample)
@@ -337,6 +337,15 @@ The :mod:`!csv` module defines the following classes:
337337
This method is a rough heuristic and may produce both false positives and
338338
negatives.
339339

340+
The :class:`Sniffer` class has the following attribute:
341+
342+
.. attribute:: preferred
343+
344+
The list of the delimiters preferred for breaking ties,
345+
in the order of preference.
346+
It can be modified.
347+
Its initial value is ``[',', '\t', ';', ' ', ':']``.
348+
340349
An example for :class:`Sniffer` use::
341350

342351
with open('example.csv', newline='') as csvfile:

0 commit comments

Comments
 (0)