[Python-checkins] cpython (2.7): #14763: fix documentation for string.split/rsplit.
ezio.melotti
python-checkins at python.org
Wed May 9 13:59:33 CEST 2012
http://hg.python.org/cpython/rev/d3ddbad31b3e
changeset: 76849:d3ddbad31b3e
branch: 2.7
parent: 76846:a775fc27f469
user: Ezio Melotti <ezio.melotti at gmail.com>
date: Wed May 09 14:59:24 2012 +0300
summary:
#14763: fix documentation for string.split/rsplit.
files:
Doc/library/string.rst | 15 ++++++++-------
1 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/Doc/library/string.rst b/Doc/library/string.rst
--- a/Doc/library/string.rst
+++ b/Doc/library/string.rst
@@ -905,14 +905,15 @@
Return a list of the words of the string *s*. If the optional second argument
*sep* is absent or ``None``, the words are separated by arbitrary strings of
- whitespace characters (space, tab, newline, return, formfeed). If the second
+ whitespace characters (space, tab, newline, return, formfeed). If the second
argument *sep* is present and not ``None``, it specifies a string to be used as
the word separator. The returned list will then have one more item than the
- number of non-overlapping occurrences of the separator in the string. The
- optional third argument *maxsplit* defaults to 0. If it is nonzero, at most
- *maxsplit* number of splits occur, and the remainder of the string is returned
- as the final element of the list (thus, the list will have at most
- ``maxsplit+1`` elements).
+ number of non-overlapping occurrences of the separator in the string.
+ If *maxsplit* is given, at most *maxsplit* number of splits occur, and the
+ remainder of the string is returned as the final element of the list (thus,
+ the list will have at most ``maxsplit+1`` elements). If *maxsplit* is not
+ specified or ``-1``, then there is no limit on the number of splits (all
+ possible splits are made).
The behavior of split on an empty string depends on the value of *sep*. If *sep*
is not specified, or specified as ``None``, the result will be an empty list.
@@ -925,7 +926,7 @@
Return a list of the words of the string *s*, scanning *s* from the end. To all
intents and purposes, the resulting list of words is the same as returned by
:func:`split`, except when the optional third argument *maxsplit* is explicitly
- specified and nonzero. When *maxsplit* is nonzero, at most *maxsplit* number of
+ specified and nonzero. If *maxsplit* is given, at most *maxsplit* number of
splits -- the *rightmost* ones -- occur, and the remainder of the string is
returned as the first element of the list (thus, the list will have at most
``maxsplit+1`` elements).
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list