[docs] [issue23406] interning and list comprehension leads to unexpected behavior
report at bugs.python.org
Tue Sep 1 04:14:49 CEST 2015
Steven D'Aprano added the comment:
Which note are you referring to? There are at least two mentioned in
this thread, the FAQ and a footnote in the docs for stdtypes.
If you're referring to the table of operations just below these:
where the docs say:
s * n, n * s n shallow copies of s concatenated
I think that could be worded better. It is too easy to misread it
as saying that the items of s are copied (as I just did now, despite
knowing that they aren't). I would word it:
repeat s n times and concatenate
which matches the common name of * as the sequence repetition operator,
and avoids using the word prone to misinterpretation, "copy".
Given how error-prone sequence repetition is, I'd add an example
directly in the table:
for example, [x]*3 returns [x, x, x] (note that x is not copied).
Python tracker <report at bugs.python.org>
More information about the docs