Re: Object containing a list of objects.

2010-08-28 Thread cocolombo
Chris I take good notice of your comments and suggestions. Thanks. -- http://mail.python.org/mailman/listinfo/python-list

Re: Object containing a list of objects.

2010-08-28 Thread cocolombo
Thanks MRAB and Peter Otten that solved the problem. -- http://mail.python.org/mailman/listinfo/python-list

Re: Object containing a list of objects.

2010-08-28 Thread Chris Rebert
On Sat, Aug 28, 2010 at 10:48 AM, cocolombo wrote: > Hello. > > I am putting objects (test) into a container object (tests) and the > test object is also a container for a another list of object > (scores). > > Problem is that all instances of class tests have the same value. > > To illustrate: >

Re: Object containing a list of objects.

2010-08-28 Thread Peter Otten
cocolombo wrote: > Problem is that all instances of class tests have the same value. > > To illustrate: > class tests(object): > listOfTest = [] This makes listOfTest a class attribute. To get one list per instance define it in the initializer: class Tests(object): def __init__(self):

Re: Object containing a list of objects.

2010-08-28 Thread MRAB
On 28/08/2010 18:48, cocolombo wrote: Hello. I am putting objects (test) into a container object (tests) and the test object is also a container for a another list of object (scores). Problem is that all instances of class tests have the same value. To illustrate: class score(object): va

Object containing a list of objects.

2010-08-28 Thread cocolombo
Hello. I am putting objects (test) into a container object (tests) and the test object is also a container for a another list of object (scores). Problem is that all instances of class tests have the same value. To illustrate: class score(object): val = 0 def __init__(self, val):