This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Underspecified behaviour of string methods split, rsplit
Type: Stage:
Components: Documentation Versions: Python 2.4
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: collinwinter, rhettinger, splitscreen
Priority: normal Keywords:

Created on 2006-01-25 15:23 by collinwinter, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg27357 - (view) Author: Collin Winter (collinwinter) * (Python committer) Date: 2006-01-25 15:23
The documentation for the string methods split and
rsplit do not address the case where sep=None and
maxsplit=0.

Should this strip off the leading and trailing
whitespace, but not do any splits? Should it simply
return the invocant string?
msg27358 - (view) Author: Matt Fleming (splitscreen) Date: 2006-02-18 12:12
Logged In: YES 
user_id=1126061

From the documentation of split()

"If maxsplit is given, splits at no more than maxsplit
places (resulting in at most maxsplit+1 words)."

I know that at the moment rsplit() and split() remove any
leading whitespace but leave trailing space intact, but I
would have thought leaving the string entirely intact would
make more sense. Surely, to comply with the statement
'resulting in at most maxsplit+1 words)' the entire string
should be returned when maxsplit=0.

I can see the point that the leading whitespace isn't
actually returned but i don't see why it should be discarded.

Just a thought.
msg27359 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2007-01-06 02:23
The docs for split() and rsplit() have reached their limits of complexity.  Let the corner cases be defined by what the implementation currently does.  IMO, any more attempts to expand these docs can only result in a decrease in clarity and usability.  What is there now does a good job at showing you what you need to know to use the methods effectively.
History
Date User Action Args
2022-04-11 14:56:15adminsetgithub: 42836
2006-01-25 15:23:41collinwintercreate