Object containing a list of objects.

Peter Otten __peter__ at web.de
Sat Aug 28 20:02:40 CEST 2010

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):
        self.tests = []


More information about the Python-list mailing list