From: J on 16 Apr 2010 15:34 On Fri, Apr 16, 2010 at 15:16, Terry Reedy <tjreedy(a)udel.edu> wrote: > On 4/16/2010 9:41 AM, J wrote: >> >> Ok... I know pretty much how .extend works on a list... basically it >> just tacks the second list to the first list... like so: >> >>>>> lista=[1] >>>>> listb=[2,3] >>>>> lista.extend(listb) >>>>> print lista; >> >> [1, 2, 3] > > This shows right here that lista is extended in place. If you are not > convinced, print(id(lista)) before and after. Thanks for the explanations, everyone... I was just a bit confused about how .extend was working... I originally thought that it returned a new object and linked lista to that, but I realize that it directly manipulates the list object instead... I'm not sure why I got that idea stuck in my head, but it was there, so I asked :)
First
|
Prev
|
Pages: 1 2 Prev: Can anyone reproduce this crash? Next: Merge two directories together |