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: fix .split() maxsplit doc, update .rsplit() docs
Type: Stage:
Components: Documentation Versions:
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: alanvgreen, calvin, rhettinger
Priority: normal Keywords: patch

Created on 2005-01-24 12:25 by calvin, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
pysplitdoc.diff calvin, 2005-01-24 12:25
pysplittests.diff calvin, 2005-01-24 12:26
Messages (7)
msg47608 - (view) Author: Bastian Kleineidam (calvin) Date: 2005-01-24 12:25
Hi,

this documentation patch for the .split() and .rsplit()
methods changes the following:
1) remove a superfluous dot in .split() method doc
2) Only if separator arg is _less than_ zero, the
number of splits is unlimited. If it is zero, the
number of splits is (correctly) zero. The "less than"
has been added.
3) The separator documentation of split() is copied
over to rsplit() documentation where it applies too.

The patch is against CVS from 20040123.
msg47609 - (view) Author: Bastian Kleineidam (calvin) Date: 2005-01-24 12:26
Logged In: YES 
user_id=9205

I also added appropriate test cases for split() and rsplit()
with negative separator argument.
msg47610 - (view) Author: Bastian Kleineidam (calvin) Date: 2005-01-24 12:29
Logged In: YES 
user_id=9205

Argl, please replace any mention of "separator" above with
"maxsplit". Sorry for the confusion.
msg47611 - (view) Author: Alan Green (alanvgreen) Date: 2005-01-25 12:40
Logged In: YES 
user_id=1174944

Docs read well and work fine. Tests pass on my linux-based
development PC. 

Please apply this patch.
msg47612 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2005-01-25 20:46
Logged In: YES 
user_id=80475

Before seeing this patch, I fixed up the related bug.
Please check the most recent update to libstdtypes.tex and
make sure it meets your needs.  If so, please close out this
patch.
msg47613 - (view) Author: Bastian Kleineidam (calvin) Date: 2005-01-25 20:59
Logged In: YES 
user_id=9205

Part 2) of the patch still applies: it should be "less than
zero" instead of just "zero". And the attached
pysplittests.diff add the appropriate test cases with "-1"
as maxsplit.
msg47614 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2005-01-26 22:52
Logged In: YES 
user_id=80475

I removed the "or is zero" phrase from the docs.  That was
clearly incorrect.  Amazingly, there were already test cases
for it.

The rest of the patch is being rejected.  The behavior for
negative values of maxsplit is an implementation quirk, not
a core feature that needs to be perpetuated through being
documented and tested.

The string module does take advantage of maxsplit=-1 as
default.   This is also an implementation specific quirk and
equivalent functionality can be had by using *args or by
having a None default followed by an if-statement.

Thanks for pointing out the documentation error in the case
where maxsplitt==0.
History
Date User Action Args
2022-04-11 14:56:09adminsetgithub: 41481
2005-01-24 12:25:50calvincreate