On 2005-02-17, Steven Bethard <[EMAIL PROTECTED]> wrote:

> py> class C(object):
> ...     def f(self, *args):
> ...         print "f:", args
> ...     def g(self, *args):
> ...         print "g:", args
> ...
> py> class D(C):
> ...     pass
> ...
> py> class Wrapper(object):
> ...     def __init__(self, func):
> ...         self.func = func
> ...     def __call__(self, *args):
> ...         print "wrapped"
> ...         return self.func(*args)
> ...
> py> for name in ['f', 'g']:
> ...     wrapper = Wrapper(getattr(C, name))
> ...     setattr(D, name, new.instancemethod(wrapper, None, D))

Thanks.  The stuff provided by the "new" module is what I was
missing.

-- 
Grant Edwards                   grante             Yow!  Wait... is this a FUN
                                  at               THING or the END of LIFE in
                               visi.com            Petticoat Junction??
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to