Automatic methods in new-style classes

2006-09-29 Thread bertgoos
Hey, I have the following code that has to send every command it
receives to a list of backends. Instead of:

class MultiBackend(object):
"""Renders to multiple backends"""

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

def flush(self):
for b in self.backends:
b.flush()

def draw(self):
for b in self.backends:
b.draw()


I would like to write each method like:

flush = multimethod()

Is that possible using new-style classes?

Bert

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


Re: Automatic methods in new-style classes

2006-09-30 Thread bertgoos
The metaclass approach seems to be the one I was looking for. Thanks!

Bert

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