gh-80678: Document the preferred attribute of csv.Sniffer (GH-155068)
serhiy-storchaka <[email protected]> Thu, 13 Aug 2026 06:01:03 -0400 (EDT)
| Newsgroups | gmane.comp.python.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://github.com/python/cpython/commit/1370f8a8a19a1201b2cc27a301a3f8f1d4478764 commit: 1370f8a8a19a1201b2cc27a301a3f8f1d4478764 branch: main author: Serhiy Storchaka <[email protected]> committer: serhiy-storchaka <[email protected]> date: 2026-08-13T13:00:30+03:00 summary: gh-80678: Document the preferred attribute of csv.Sniffer (GH-155068) It can be modified to change the order in which the delimiters are preferred for breaking ties. files: M Doc/library/csv.rst diff --git a/Doc/library/csv.rst b/Doc/library/csv.rst index 81949261c563d0..e78371f114e0a1 100644 --- a/Doc/library/csv.rst +++ b/Doc/library/csv.rst @@ -324,8 +324,8 @@ The :mod:`!csv` module defines the following classes: If several combinations fit the sample equally well --- for example if both ``','`` and ``';'`` split every row consistently --- - the delimiters ``','``, ``'\t'``, ``';'``, ``' '`` and ``':'`` - are preferred, in this order, + the delimiters listed in the :attr:`~Sniffer.preferred` attribute + are preferred, in that order, no matter how many times each of them occurs. .. versionchanged:: next @@ -354,6 +354,15 @@ The :mod:`!csv` module defines the following classes: This method is a rough heuristic and may produce both false positives and negatives. + The :class:`Sniffer` class has the following attribute: + + .. attribute:: preferred + + The list of the delimiters preferred for breaking ties, + in the order of preference. + It can be modified. + Its initial value is ``[',', '\t', ';', ' ', ':']``. + An example for :class:`Sniffer` use:: with open('example.csv', newline='') as csvfile: _______________________________________________ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]