[Svnmerge] [PATCH] Read command line defaults from config file
Michael Haggerty
mhagger at alum.mit.edu
Thu Sep 21 10:48:44 PDT 2006
Rich Williams wrote:
> Python question - what's the different between + and extend? (To be
> honest, it took me a while to find 'extend' - I'd been using 'append').
"+" creates a new list containing the contents of the first two.
append() adds an element to a list in-place
extend() adds multiple elements to a list in-place
"+=" is equivalent to extend()
Example:
>>> a = [1,2]
>>> b = a
>>> b = b + [3,4]
>>> # a is unaffected by this reassignment of b
>>> print a
[1, 2]
>>> b = a
>>> b.extend([3,4])
>>> # This time a is affected too, because the modification was in-place
>>> print a
[1, 2, 3, 4]
>>>
Michael
More information about the Svnmerge
mailing list