neoedmund wrote:

> Could you show some code to help me know how composition/delegation can
> be done here? Thanks.

Starting with your example C2 might just derive from C1 and perform a
supercall:

class C1(object):
        def v(self, o):
                return "expected "+o


class C2(C1):
        def v(self, o):
                return "unexpected "+o
        def m(self):
                print super(C2,self).v("aaa")

>>> c2 = C2()
>>> c2.m()
expected aaa

But in general there is no single pattern to deal with object
composition.

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to