On Fri, 29 Jul 2005 22:34:23 +0800,
"flyaflya" <[EMAIL PROTECTED]> wrote:
> the codes as follow:
> class Base:
> def fun(self):
> print "base_fun"
> def fun2(self):
> print "base_fun2"
> class Foo:
> def __init__(self, base):
> self.__base = base
> def fun3(self):
> print "foo_fun3"
> b = Base()
> foo = Foo(b)
> my aim is:when "foo.fun3()" be called,it run as usually, but when
> "foo.fun()" or "foo.fun2() be called, as Foo hasn't attribute "fun()" and
> "fun2()", foo will call "self.__base.fun()" or "self.__base.fun2()".
> when a attr can't be find in foo, it's will try to search 'self.__base". I
> think this maybe need to use "__getattr__" and "__setattr__" ,but I cant do
> it successfully. can someone help me?
class Foo(Base):
def fun3(self):
print "fun_foo3"
HTH,
Dan
--
Dan Sommers
<http://www.tombstonezero.net/dan/>
--
http://mail.python.org/mailman/listinfo/python-list