Message366887
The section mentions the usage of `str.join` and contains the following example:
chunks = []
for s in my_strings:
chunks.append(s)
result = ''.join(chunks)
Since `join` accepts any iterable the creation of the `chunks` list in a for loop is superfluous. If people just copy & paste from this FAQ they'll even end up with less performant code.
The example could be improved by providing an example list such as:
strings = ['spam', 'ham', 'eggs']
meal = ', '.join(strings)
Arguably this isn't a particularly long list of strings, so one more example could be added using e.g. `range(100)`:
numbers = ','.join(str(x) for x in range(100))
This also emphasizes the fact that `join` takes any iterable rather than just lists. |
|
Date |
User |
Action |
Args |
2020-04-20 21:27:30 | Dominik V. | set | recipients:
+ Dominik V., docs@python |
2020-04-20 21:27:30 | Dominik V. | set | messageid: <1587418050.72.0.944089786988.issue40344@roundup.psfhosted.org> |
2020-04-20 21:27:30 | Dominik V. | link | issue40344 messages |
2020-04-20 21:27:30 | Dominik V. | create | |
|