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 _______________________________________________ Svnmerge mailing list [email protected] http://www.orcaware.com/mailman/listinfo/svnmerge
