list.extend([]) Question
Andre Engels
andreengels at gmail.com
Sat Jan 30 10:41:45 EST 2010
On Sat, Jan 30, 2010 at 4:32 PM, Dan Brown <fsenzeru at gmail.com> wrote:
> Why does extending a list with the empty list result in None? It
> seems very counterintuitive to me, at least --- I expected ['a'].extend
> ([]) to result in ['a'], not None.
Extend is a method of the list. The list itself is changed, it does
not return itself:
>>> A = [1,2]
>>> B = [3,4]
>>> C = A.extend(B)
>>> C
>>> C is None
True
>>> A
[1, 2, 3, 4]
Thus, nothing special about extend([]), this is the general behaviour of extend
--
André Engels, andreengels at gmail.com
More information about the Python-list
mailing list