classification
Title: Inconsistency in docs for list.extend
Type: Stage: resolved
Components: Documentation Versions: Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: Andrew Cameron, docs@python, martin.panter, python-dev
Priority: normal Keywords:

Created on 2016-06-22 18:29 by Andrew Cameron, last changed 2016-06-23 01:11 by martin.panter. This issue is now closed.

Messages (3)
msg269080 - (view) Author: Andrew Cameron (Andrew Cameron) Date: 2016-06-22 18:29
The documentation for Mutable Sequence Types states that, for operation:
s.extend(x) or s += t

the expected result is:
for the most part the same as s[len(s):len(s)] = x

Note that if you perform operation 's += t' the result is not the same as 's[len(s):len(s)] = x' unless 't == x'.

This does not occur with the Python 3 docs, which uses exclusively 't' (not 'x'). However for people reading the Python 2 docs the variable mix-up could cause confusion.
msg269097 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-06-23 00:57
New changeset c91007ab3fda by Martin Panter in branch '2.7':
Issue #27370: Use t for an iterable in mutable sequence ops
https://hg.python.org/cpython/rev/c91007ab3fda
msg269099 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2016-06-23 01:11
The t vs x mixup was introduced by my sloppy backport in Issue 16701. The other problem here is x is generally defined as any arbitrary object, but redefined as an iterable in the footnote. I think we should use t instead, as in the other two slice assignment operations and in Python 3. My commit should have fixed both these problems.
History
Date User Action Args
2016-06-23 01:11:07martin.pantersetstatus: open -> closed

nosy: + martin.panter
messages: + msg269099

resolution: fixed
stage: resolved
2016-06-23 00:57:58python-devsetnosy: + python-dev
messages: + msg269097
2016-06-22 18:29:00Andrew Cameroncreate