[Python-checkins] cpython (merge 3.2 -> default): #14957: clarify splitlines docs.
r.david.murray
python-checkins at python.org
Fri Jun 1 22:21:23 CEST 2012
http://hg.python.org/cpython/rev/2a43088318ed
changeset: 77289:2a43088318ed
parent: 77287:d7c4089e9637
parent: 77288:24572015e24f
user: R David Murray <rdmurray at bitdance.com>
date: Fri Jun 01 16:20:26 2012 -0400
summary:
#14957: clarify splitlines docs.
Initial patch by Michael Driscoll, I added the example.
files:
Doc/library/stdtypes.rst | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst
--- a/Doc/library/stdtypes.rst
+++ b/Doc/library/stdtypes.rst
@@ -1353,7 +1353,13 @@
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.
+ 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.
+
+ For example, ``'ab c\n\nde fg\rkl\r\n'.splitlines()`` returns
+ ``['ab c', '', 'de fg', 'kl']``, while the same call with ``splinelines(True)``
+ returns ``['ab c\n', '\n, 'de fg\r', 'kl\r\n']``.
.. method:: str.startswith(prefix[, start[, end]])
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list