nesting objects
Bengt Richter
bokr at oz.net
Tue Feb 11 22:27:47 EST 2003
On Wed, 12 Feb 2003 00:34:40 GMT, jef.mangelschots at iname.com (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()
Regards,
Bengt Richter
More information about the Python-list
mailing list