nesting objects

Bengt Richter bokr at
Wed Feb 12 04:27:47 CET 2003

On Wed, 12 Feb 2003 00:34:40 GMT, jef.mangelschots at (Jef Mangelschots) wrote:

>I want to nest objects of different types.
>I tried this in the following example, but I get an error (see below).
>What am I doing wrong ?

I'm not sure what you are doing, but you got the error
because you forgot to use "self."

(The bare "aggregate" only created a local binding in the
__init__ method, not an attribute of the instance bound to self).
>>>>>code snippet<<<<<<<<<<
>class C1:
>    c1_1 = ""
>class C2:
>    c2_1 = ""
>    def __init__(self):
>        aggregate  = C1()
         self.aggregate  = C1()

Bengt Richter

More information about the Python-list mailing list