[Python-checkins] GH-99183: Document behavior of count() for empty substrings (GH-99339)

miss-islington webhook-mailer at python.org
Thu Nov 10 16:27:48 EST 2022


https://github.com/python/cpython/commit/f7d3b18ed5369869dc7abf13adf12dff6e03c043
commit: f7d3b18ed5369869dc7abf13adf12dff6e03c043
branch: 3.10
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: miss-islington <31488909+miss-islington at users.noreply.github.com>
date: 2022-11-10T13:27:42-08:00
summary:

GH-99183: Document behavior of count() for empty substrings (GH-99339)

(cherry picked from commit 2f4af2d99cffed6ba81e4b8fd886de6ae8625a3f)

Co-authored-by: Raymond Hettinger <rhettinger at users.noreply.github.com>

files:
M Doc/library/stdtypes.rst

diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst
index 1dbf3e2f8815..8f90bd3efa6c 100644
--- a/Doc/library/stdtypes.rst
+++ b/Doc/library/stdtypes.rst
@@ -1579,6 +1579,9 @@ expression support in the :mod:`re` module).
    range [*start*, *end*].  Optional arguments *start* and *end* are
    interpreted as in slice notation.
 
+   If *sub* is empty, returns the number of empty strings between characters
+   which is the length of the string plus one.
+
 
 .. method:: str.encode(encoding="utf-8", errors="strict")
 
@@ -2658,6 +2661,9 @@ arbitrary binary data.
    The subsequence to search for may be any :term:`bytes-like object` or an
    integer in the range 0 to 255.
 
+   If *sub* is empty, returns the number of empty slices between characters
+   which is the length of the bytes object plus one.
+
    .. versionchanged:: 3.3
       Also accept an integer in the range 0 to 255 as the subsequence.
 



More information about the Python-checkins mailing list