Fredrik Lundh wrote: > John Salerno wrote: > >> Steven Bethard wrote: >> >> >>> lst[:] = [] >>> lst = [] >> What's the difference here? > > L[:]= modifies the object in place, L=[] binds the variable to a > new object. compare and contrast:
Thanks guys, your explanations are really helpful. I think what had me confused at first was my understanding of what L[:] does on either side of the assignment operator. On the left, it just chooses those elements and edits them in place; on the right, it makes a copy of that list, right? (Which I guess is still more or less *doing* the same thing, just for different purposes) -- http://mail.python.org/mailman/listinfo/python-list