[EMAIL PROTECTED] wrote:
> Hey, I want to send commands to a list of backends:

How about something like:


class Forwards(object):

     to_forward = set(['flush', 'read', 'write', 'close'])

     def __init__(self, backends):
         self.backends = backends

     def forwarder(self, methodname):
         def method(*args, **kwargs):
             for b in self.backends:
                 getattr(b, methodname)(*args, **kwargs)
         return forwarder

     def __getattr__(self, name):
         if name in self.to_forward:
             return self.forwarder(name)
         raise AttributeError("%r object has no attribute %r"
                              % (self.__class__.__name__, name))

--Scott David Daniels
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to