On Wed, Sep 9, 2009 at 10:08 AM, 一首诗<newpt...@gmail.com> wrote: > But when C has many many methods to expose to outer user, 2nd choice > seems to be more reasonable I In the first design, B.newMethod did > nothing really useful.
Is there any reason you can't do something like the following? class B(object): def __init__(self, c): self.__c = c; def __getattr__(self, name): return self.__c.__getattribute__(name) class C(object): def sayHi(self): print "c says hi" So that when you call B and it doesn't have the attribute, it looks at it's instance of C? \t -- http://mail.python.org/mailman/listinfo/python-list