nesting objects

Jef Mangelschots jef.mangelschots at iname.com
Tue Feb 11 19:34:40 EST 2003


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 ?


>>>>code snippet<<<<<<<<<<
class C1:
    c1_1 = ""

class C2:
    c2_1 = ""
    def __init__(self):
        aggregate  = C1()


example = C2()

example.aggregate.c1_1 = "howdie"

print "test: " + example.aggregate.c1_1

>>>>code snippet<<<<<<<<<<


>>>>output<<<<<<<<<<

Traceback (most recent call last):
  File "test5.py", line 23, in ?
    example.aggregate.c1_1 = "howdie"
AttributeError: C2 instance has no attribute 'aggregate'

>>>>output<<<<<<<<<<






More information about the Python-list mailing list