Appending a list's elements to another list using a list comprehension

Hrvoje Niksic hniksic at xemacs.org
Thu Oct 18 09:07:22 EDT 2007


Paul Hankin <paul.hankin at gmail.com> writes:

> Not to me: I can never remember which of a.append and a.extend is
> which.

Interesting, with me it's the other way around.  Maybe it's because I
used Python before extend was available.

> Falling back to a = a + b is exactly what you want.

Not if you want to mutate the original object, possibly referenced
from elsewhere.



More information about the Python-list mailing list