Skip to content

gh-110383: Improve accuracy of str.split() and str.rsplit() docstrings - #113355

Merged
erlend-aasland merged 1 commit into
python:mainfrom
erlend-aasland:splitter!
Dec 21, 2023
Merged

gh-110383: Improve accuracy of str.split() and str.rsplit() docstrings#113355
erlend-aasland merged 1 commit into
python:mainfrom
erlend-aasland:splitter!

Conversation

@erlend-aasland

@erlend-aaslanderlend-aasland commented Dec 21, 2023

Copy link
Copy Markdown
Contributor

Mention split direction in the docstring body,
instead of in the 'maxsplit' param docstring.

…strings
Mention split direction in the docstring body,
instead of in the 'maxsplit' param docstring.
@erlend-aasland

Copy link
Copy Markdown
ContributorAuthor

Alternative to #111247 and #113353.

@hugovkhugovk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good:

❯ ./python.exe
Python 3.13.0a2+ (heads/splitter!-dirty:c50dd463dd, Dec 21 2023, 14:51:45) [Clang 15.0.0 (clang-1500.1.0.2.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> help(str().split)
Help on built-in function split:
split(sep=None, maxsplit=-1) method of builtins.str instance
Return a list of the substrings in the string, using sep as the separator string.
sep
The separator used to split the string.
When set to None (the default value), will split on any whitespace
character (including \n \r \t \f and spaces) and will discard
empty strings from the result.
maxsplit
Maximum number of splits.
-1 (the default value) means no limit.
Splitting starts at the front of the string and works to the end.
Note, str.split() is mainly useful for data that has been intentionally
delimited. With natural text that includes punctuation, consider using
the regular expression module.
>>> help(str().rsplit)
Help on built-in function rsplit:
rsplit(sep=None, maxsplit=-1) method of builtins.str instance
Return a list of the substrings in the string, using sep as the separator string.
sep
The separator used to split the string.
When set to None (the default value), will split on any whitespace
character (including \n \r \t \f and spaces) and will discard
empty strings from the result.
maxsplit
Maximum number of splits.
-1 (the default value) means no limit.
Splitting starts at the end of the string and works to the front.
>>>

Thanks everyone!

@miss-islington-app

This comment was marked as outdated.

@miss-islington-app

This comment was marked as outdated.

@miss-islington-app

This comment was marked as outdated.

@bedevere-bot

This comment was marked as off-topic.

@bedevere-app

Copy link
Copy Markdown

GH-113379 is a backport of this pull request to the 3.12 branch.

@bedevere-appbedevere-appBot removed the needs backport to 3.12 only security fixes label Dec 21, 2023
hugovk pushed a commit to hugovk/cpython that referenced this pull request Dec 21, 2023
…t() docstrings (pythonGH-113355)
Clarify split direction in the docstring body,
instead of in the 'maxsplit' param docstring.
(cherry picked from commit 526d0a9)
Co-authored-by: Erlend E. Aasland <erlend@python.org>
@bedevere-app

Copy link
Copy Markdown

GH-113380 is a backport of this pull request to the 3.11 branch.

@bedevere-appbedevere-appBot removed the needs backport to 3.11 only security fixes label Dec 21, 2023
hugovk pushed a commit to hugovk/cpython that referenced this pull request Dec 21, 2023
…t() docstrings (pythonGH-113355)
Clarify split direction in the docstring body,
instead of in the 'maxsplit' param docstring.
(cherry picked from commit 526d0a9)
Co-authored-by: Erlend E. Aasland <erlend@python.org>
hugovk added a commit that referenced this pull request Dec 22, 2023
…cstrings (GH-113355) (#113379)
Co-authored-by: Erlend E. Aasland <erlend@python.org>
hugovk added a commit that referenced this pull request Dec 22, 2023
…cstrings (GH-113355) (#113380)
Co-authored-by: Erlend E. Aasland <erlend@python.org>
ryan-duve pushed a commit to ryan-duve/cpython that referenced this pull request Dec 26, 2023
…strings (python#113355)
Clarify split direction in the docstring body,
instead of in the 'maxsplit' param docstring.
kulikjak pushed a commit to kulikjak/cpython that referenced this pull request Jan 22, 2024
…strings (python#113355)
Clarify split direction in the docstring body,
instead of in the 'maxsplit' param docstring.
aisk pushed a commit to aisk/cpython that referenced this pull request Feb 11, 2024
…strings (python#113355)
Clarify split direction in the docstring body,
instead of in the 'maxsplit' param docstring.
Glyphack pushed a commit to Glyphack/cpython that referenced this pull request Sep 2, 2024
…strings (python#113355)
Clarify split direction in the docstring body,
instead of in the 'maxsplit' param docstring.
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@erlend-aasland@bedevere-bot@hugovk