From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Thu, 10 Nov 2022 21:29:16 +0000 (-0800) Subject: GH-99183: Document behavior of count() for empty substrings (GH-99339) X-Git-Tag: v3.11.1~105 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=17f1c0ab061b02d2f1c3d36ee33e2252c0a10e16;p=thirdparty%2FPython%2Fcpython.git GH-99183: Document behavior of count() for empty substrings (GH-99339) (cherry picked from commit 2f4af2d99cffed6ba81e4b8fd886de6ae8625a3f) Co-authored-by: Raymond Hettinger --- diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 68b333acd8f0..75550d6e4698 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -1617,6 +1617,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") @@ -2698,6 +2701,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.