[Python-checkins] cpython (3.2): #15554: clarify splitlines/split differences.
r.david.murray
python-checkins at python.org
Mon Aug 6 22:09:48 CEST 2012
http://hg.python.org/cpython/rev/768b188262e7
changeset: 78453:768b188262e7
branch: 3.2
parent: 78449:3fe01f7520e2
user: R David Murray <rdmurray at bitdance.com>
date: Mon Aug 06 16:08:09 2012 -0400
summary:
#15554: clarify splitlines/split differences.
Patch by Chris Jerdonek.
files:
Doc/library/stdtypes.rst | 13 ++++++++-----
1 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst
--- a/Doc/library/stdtypes.rst
+++ b/Doc/library/stdtypes.rst
@@ -1327,16 +1327,19 @@
.. method:: str.splitlines([keepends])
- Return a list of the lines in the string, breaking at line boundaries. Line
- breaks are not included in the resulting list unless *keepends* is given and
- true. This method uses the universal newlines approach to splitting lines.
- Unlike :meth:`~str.split`, if the string ends with line boundary characters
- the returned list does ``not`` have an empty last element.
+ Return a list of the lines in the string, breaking at line boundaries.
+ This method uses the universal newlines approach to splitting lines.
+ Line breaks are not included in the resulting list unless *keepends* is
+ given and true.
For example, ``'ab c\n\nde fg\rkl\r\n'.splitlines()`` returns
``['ab c', '', 'de fg', 'kl']``, while the same call with ``splitlines(True)``
returns ``['ab c\n', '\n, 'de fg\r', 'kl\r\n']``.
+ Unlike :meth:`~str.split` when a delimiter string *sep* is given, this
+ method returns an empty list for the empty string, and a terminal line
+ break does not result in an extra line.
+
.. method:: str.startswith(prefix[, start[, end]])
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list