[docs] [issue23406] interning and list comprehension leads to unexpected behavior
Steven D'Aprano
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:
https://docs.python.org/2/library/stdtypes.html#sequence-types-str-unicode-list-tuple-bytearray-buffer-xrange
https://docs.python.org/3/library/stdtypes.html#common-sequence-operations
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>
<http://bugs.python.org/issue23406>
_______________________________________
More information about the docs
mailing list