LibRef 2.2.6.4 Mutable Sequence Types footnote (2)
(current version)to S.extend(x) says "Raises an
exception when x is not a list object." Similarly,
>>> a.extend.__doc__
'L.extend(list) -- extend list by appending list elements'
However, x need only be iterable. For instance (2.2.1)
>>> a.extend('ab')
>>> a
[1, 2, 3, 'a', 'b']
>> from __future__ import generators
>>> def f(n):
... for i in range(n): yield i
...
>>> a.extend(f(3))
>>> a
[1, 2, 3, 'a', 'b', 0, 1, 2]
Error message has already been updated:
>>> a.extend(1)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: list.extend() argument must be iterable
Question: footnote 2 also says "The extend() method
is experimental". Still true after two additional
releases, or time to delete this?
The continuation "and not supported by mutable
sequence types other than lists. " seems rather moot
(and delete-able) unless and until another m.s.t is
added.
|