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

This commit is contained in:
Raymond Hettinger 2022-11-10 15:20:01 -06:00 committed by GitHub
parent dbf8613a2e
commit 2f4af2d99c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 0 deletions

View File

@ -1617,6 +1617,9 @@ expression support in the :mod:`re` module).
range [*start*, *end*]. Optional arguments *start* and *end* are range [*start*, *end*]. Optional arguments *start* and *end* are
interpreted as in slice notation. 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") .. 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 The subsequence to search for may be any :term:`bytes-like object` or an
integer in the range 0 to 255. 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 .. versionchanged:: 3.3
Also accept an integer in the range 0 to 255 as the subsequence. Also accept an integer in the range 0 to 255 as the subsequence.