Suppose I have two Python classes, A and B. I would like to be able to do the following:
>>> b = B()
>>> b.a.attr1 = 'foo'
>>> b.a.attr2 = 'bar'
where 'a' is an instance of A. I can't use __setattr__ as I would if 'a' was some
"primitive" type. Is there some elegant way to accomplish this, other than
>>> b = B()
>>> b.a = A()
>>> b.a.attr1 = 'foo'
>>> b.a.attr2 = 'bar'
?
self.a = A()intoB.__init__method?__init__(potentially) won't be used. Also, some code in A() may fire at__init__time that I won't necessarily be ready for. Thanks.