summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2012-06-01 20:21:06 (GMT)
committerR David Murray <rdmurray@bitdance.com>2012-06-01 20:21:06 (GMT)
commit4fbf7c61fea1cdce8487ed9582ab9ba73fcf53ea (patch)
treee20cdaa5797b3ee1595c49c7ab7995458f5475b9
parent5e247b705e3bdd77967bca76601b791003389ada (diff)
downloadcpython-4fbf7c61fea1cdce8487ed9582ab9ba73fcf53ea.zip
cpython-4fbf7c61fea1cdce8487ed9582ab9ba73fcf53ea.tar.gz
cpython-4fbf7c61fea1cdce8487ed9582ab9ba73fcf53ea.tar.bz2
#14957: clarify splitlines docs.
Initial patch by Michael Driscoll, I added the example.
-rw-r--r--Doc/library/stdtypes.rst8
1 files changed, 7 insertions, 1 deletions
diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst
index cebe752..66facca 100644
--- a/Doc/library/stdtypes.rst
+++ b/Doc/library/stdtypes.rst
@@ -1185,7 +1185,13 @@ string functions based on regular expressions.
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]])