diff options
author | R David Murray <rdmurray@bitdance.com> | 2012-06-01 20:19:36 (GMT) |
---|---|---|
committer | R David Murray <rdmurray@bitdance.com> | 2012-06-01 20:19:36 (GMT) |
commit | ae1b94b6e4091f9b8c9249ad535a2f121030dd2e (patch) | |
tree | 4a7313d4a6fd6975338325a0df2e10eba4f89bc8 /Doc | |
parent | 3f7d1d33030c3cd7bedf78c746d2641e5d444600 (diff) | |
download | cpython-ae1b94b6e4091f9b8c9249ad535a2f121030dd2e.zip cpython-ae1b94b6e4091f9b8c9249ad535a2f121030dd2e.tar.gz cpython-ae1b94b6e4091f9b8c9249ad535a2f121030dd2e.tar.bz2 |
#14957: clarify splitlines docs.
Initial patch by Michael Driscoll, I added the example.
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/stdtypes.rst | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index b89387f..8f7fc5c 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -1329,7 +1329,13 @@ 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]]) |