I have a MixIn class which defines a method foo(), and is then mixed in
with another class by being prepended to that class's __bases__ member,
thus overriding that class's definition of foo().  In my application
though it is necessary for the MixIn's foo() to call the overridden
foo().  How can I do this?

My current hack is to do this:

def foo():  # MixIn's method
    orig_bases = self.__class__.__bases__
    bases = list(orig_bases)
    bases.remove(OptEdgeCache)
    self.__class__.__bases__ = tuple(bases)
    foo_orig = self.foo
    self.__class__.__bases__ = orig_bases

    # other stuff here...


Is there a better way?  Does the above even work as I think it does?

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

Reply via email to