On Sep 27, 11:38 pm, "Dmitry S. Makovey" <[EMAIL PROTECTED]> wrote: > George Sakkis wrote: > > It's funny how often you come with a better solution a few moments > > after htting send! The snippet above can (ab)use the decorator syntax > > so that it becomes: > > > class A(Proxy): > > > @ProxyMethod > > def bmethod(self): > > return self.b1 > > > @ProxyMethod > > def bmethod2(self): > > return self.b2 > > That is outstanding!
FYI, in case you missed it the final version doesn't need a Proxy base class, just inherit from object. Also lowercased ProxyMethod to look similar to staticmethod/classmethod: class A(object): def __init__(self, b1, b2): self.b1 = b1 self.b2 = b2 @proxymethod def bmethod(self): return self.b1 @proxymethod def bmethod2(self): return self.b2 George -- http://mail.python.org/mailman/listinfo/python-list