GeezerVison is showing github.com — gh-106318: Add examples for str.join() (GH-140315) · miss-islington/cpython@4c1c99e
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: Doc/library/stdtypes.rst +12-1Lines changed: 12 additions & 1 deletion - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -2222,7 +2222,16 @@ expression support in the :mod:`re` module). |
2222 | 2222 | Return a string which is the concatenation of the strings in *iterable*. |
2223 | 2223 | A :exc:`TypeError` will be raised if there are any non-string values in |
2224 | 2224 | *iterable*, including :class:`bytes` objects. The separator between |
2225 | | - elements is the string providing this method. |
| 2225 | + elements is the string providing this method. For example: |
| 2226 | + |
| 2227 | + .. doctest:: |
| 2228 | + |
| 2229 | + >>> ', '.join(['spam', 'spam', 'spam']) |
| 2230 | + 'spam, spam, spam' |
| 2231 | + >>> '-'.join('Python') |
| 2232 | + 'P-y-t-h-o-n' |
| 2233 | + |
| 2234 | + See also :meth:`split`. |
2226 | 2235 |
|
2227 | 2236 |
|
2228 | 2237 | .. method:: str.ljust(width, fillchar=' ', /) |
@@ -2436,6 +2445,8 @@ expression support in the :mod:`re` module). |
2436 | 2445 | >>> " foo ".split(maxsplit=0) |
2437 | 2446 | ['foo '] |
2438 | 2447 |
|
| 2448 | + See also :meth:`join`. |
| 2449 | + |
2439 | 2450 |
|
2440 | 2451 | .. index:: |
2441 | 2452 | single: universal newlines; str.splitlines method |
|