Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(4843)

Side by Side Diff: Doc/library/stdtypes.rst

Issue 15554: correct and clarify str.splitlines() documentation
Patch Set: Created 9 months, 3 weeks ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 .. XXX: reference/datamodel and this have quite a few overlaps! 1 .. XXX: reference/datamodel and this have quite a few overlaps!
2 2
3 3
4 .. _bltin-types: 4 .. _bltin-types:
5 5
6 ************** 6 **************
7 Built-in Types 7 Built-in Types
8 ************** 8 **************
9 9
10 The following sections describe the standard types that are built into the 10 The following sections describe the standard types that are built into the
(...skipping 1333 matching lines...) Expand 10 before | Expand all | Expand 10 after
1344 string has leading or trailing whitespace. Consequently, splitting an empty 1344 string has leading or trailing whitespace. Consequently, splitting an empty
1345 string or a string consisting of just whitespace with a ``None`` separator 1345 string or a string consisting of just whitespace with a ``None`` separator
1346 returns ``[]``. 1346 returns ``[]``.
1347 1347
1348 For example, ``' 1 2 3 '.split()`` returns ``['1', '2', '3']``, and 1348 For example, ``' 1 2 3 '.split()`` returns ``['1', '2', '3']``, and
1349 ``' 1 2 3 '.split(None, 1)`` returns ``['1', '2 3 ']``. 1349 ``' 1 2 3 '.split(None, 1)`` returns ``['1', '2 3 ']``.
1350 1350
1351 1351
1352 .. method:: str.splitlines([keepends]) 1352 .. method:: str.splitlines([keepends])
1353 1353
1354 Return a list of the lines in the string, breaking at line boundaries. Line 1354 Return a list of the lines in the string, breaking at line boundaries.
1355 breaks are not included in the resulting list unless *keepends* is given and 1355 This method uses the universal newlines approach to splitting lines.
1356 true. This method uses the universal newlines approach to splitting lines. 1356 Line breaks are not included in the resulting list unless *keepends* is
1357 Unlike :meth:`~str.split`, if the string ends with line boundary characters 1357 given and true.
1358 the returned list does ``not`` have an empty last element.
1359 1358
1360 For example, ``'ab c\n\nde fg\rkl\r\n'.splitlines()`` returns 1359 For example, ``'ab c\n\nde fg\rkl\r\n'.splitlines()`` returns
1361 ``['ab c', '', 'de fg', 'kl']``, while the same call with ``splitlines(True)` ` 1360 ``['ab c', '', 'de fg', 'kl']``, while the same call with ``splitlines(True)` `
1362 returns ``['ab c\n', '\n, 'de fg\r', 'kl\r\n']``. 1361 returns ``['ab c\n', '\n, 'de fg\r', 'kl\r\n']``.
1363 1362
1363 Unlike :meth:`~str.split` when a delimiter string *sep* is given, this
1364 method returns an empty list for the empty string, and a terminal line
1365 break does not result in an extra line.
1366
1364 1367
1365 .. method:: str.startswith(prefix[, start[, end]]) 1368 .. method:: str.startswith(prefix[, start[, end]])
1366 1369
1367 Return ``True`` if string starts with the *prefix*, otherwise return ``False` `. 1370 Return ``True`` if string starts with the *prefix*, otherwise return ``False` `.
1368 *prefix* can also be a tuple of prefixes to look for. With optional *start*, 1371 *prefix* can also be a tuple of prefixes to look for. With optional *start*,
1369 test string beginning at that position. With optional *end*, stop comparing 1372 test string beginning at that position. With optional *end*, stop comparing
1370 string at that position. 1373 string at that position.
1371 1374
1372 1375
1373 .. method:: str.strip([chars]) 1376 .. method:: str.strip([chars])
(...skipping 1748 matching lines...) Expand 10 before | Expand all | Expand 10 after
3122 .. [2] As a consequence, the list ``[1, 2]`` is considered equal to ``[1.0, 2.0] ``, and 3125 .. [2] As a consequence, the list ``[1, 2]`` is considered equal to ``[1.0, 2.0] ``, and
3123 similarly for tuples. 3126 similarly for tuples.
3124 3127
3125 .. [3] They must have since the parser can't tell the type of the operands. 3128 .. [3] They must have since the parser can't tell the type of the operands.
3126 3129
3127 .. [4] Cased characters are those with general category property being one of 3130 .. [4] Cased characters are those with general category property being one of
3128 "Lu" (Letter, uppercase), "Ll" (Letter, lowercase), or "Lt" (Letter, titlecas e). 3131 "Lu" (Letter, uppercase), "Ll" (Letter, lowercase), or "Lt" (Letter, titlecas e).
3129 3132
3130 .. [5] To format only a tuple you should therefore provide a singleton tuple who se only 3133 .. [5] To format only a tuple you should therefore provide a singleton tuple who se only
3131 element is the tuple to be formatted. 3134 element is the tuple to be formatted.
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld cbc36f91f3f7