diff options
author | R David Murray <rdmurray@bitdance.com> | 2012-06-01 20:20:26 (GMT) |
---|---|---|
committer | R David Murray <rdmurray@bitdance.com> | 2012-06-01 20:20:26 (GMT) |
commit | 5a0d4391265824de4af3a0dbf473e0b1b493bbba (patch) | |
tree | 7126591b7b5dbac8e8488df189d282909ece8e0b | |
parent | be1bc8c41027ddbc9cb8b112dff5664aa02a631a (diff) | |
parent | ae1b94b6e4091f9b8c9249ad535a2f121030dd2e (diff) | |
download | cpython-5a0d4391265824de4af3a0dbf473e0b1b493bbba.zip cpython-5a0d4391265824de4af3a0dbf473e0b1b493bbba.tar.gz cpython-5a0d4391265824de4af3a0dbf473e0b1b493bbba.tar.bz2 |
#14957: clarify splitlines docs.
Initial patch by Michael Driscoll, I added the example.
-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 bf86d8eb..b01c892 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -1353,7 +1353,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]]) |