Issue 27370: Inconsistency in docs for list.extend (original) (raw)

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.

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.