2005/9/9, Ksenia Marasanova <[EMAIL PROTECTED]>: > class BasemethodMeta(type): > def __new__(cls, class_name, bases, new_attrs): > cls = type.__new__(cls, class_name, bases, new_attrs) > new_attrs['__metaclass__'].cls = cls > return cls > > def __call__(self): > return self.cls.get_foo() > > class Basemethod(object): > __metaclass__ = BasemethodMeta > def get_foo(cls): > return cls.foo > get_foo = classmethod(get_foo) > > > But it doesn't work as I expected: > > print Class.method1() > "foo2" > print Class.method2() > "foo2"
As usual, it helps to write things down :) I found an alternative way, probably a lot easier to maintain: return *instance* of Basemethod class in __new__ method of the BasemethodMeta, and then use __call__ method of Basemethod class for all the things. Python is such fun... -- Ksenia -- http://mail.python.org/mailman/listinfo/python-list