Re: List append

2007-09-15 Thread Steve Holden
Rob E wrote: > On Sat, 15 Sep 2007 03:25:27 +, mouseit wrote: > >> I'm trying to add an element to a list which is a property of an >> object, stored in an array. When I append to one element, all of the >> lists are appended! >> >> Example Code: >> >> class Test: >> array = [] >> >> myTes

Re: List append

2007-09-15 Thread Rob E
On Sat, 15 Sep 2007 03:25:27 +, mouseit wrote: > I'm trying to add an element to a list which is a property of an > object, stored in an array. When I append to one element, all of the > lists are appended! > > Example Code: > > class Test: > array = [] > > myTests = [Test() , Test() ,

Re: List append

2007-09-14 Thread mouseit
On Sep 14, 11:42 pm, Stephen <[EMAIL PROTECTED]> wrote: > In your code, "array" is a class attribute, so it is shared among all > instances. You need to use the __init__ method to define instance > (data) attributes instead: > > def __init__(self): > self.array = [] > > On Sep 14, 11:25 pm, mou

Re: List append

2007-09-14 Thread Stephen
In your code, "array" is a class attribute, so it is shared among all instances. You need to use the __init__ method to define instance (data) attributes instead: def __init__(self): self.array = [] On Sep 14, 11:25 pm, mouseit <[EMAIL PROTECTED]> wrote: > I'm trying to add an element to a li