On Sun, Jul 27, 2008 at 11:28 AM, John Hunter <[EMAIL PROTECTED]> wrote:
> On a separate note, I also see the strangeness you are seeing with the > multiple inheritance order. When I run the example with backend > wxagg, I get the wx specialization called even though FigureCanvasAgg > is defined first in the multiple inheritance heirarchy and so the base > method should be picked up. And yet when I try and replicate this in > test code, I always get the base class method ... Looks like we've > got some work to do to sort all of this out. One possibility: since FigureCanvasWx inherits not only from FigureCanvasBase, but also wx.Panel which is a SWIG object (eg look at the repr of FigureCanvasWXAgg) <matplotlib.backends.backend_wxagg.FigureCanvasWxAgg; proxy of <Swig Object of type 'wxPanel *' at 0x10117b30> > is it possible that the swig part is doing some deep magic that screws w/ the normal python mulitlple inheritance lookup ? I just confirmed that something like this appears to be the case -- if you add the wx panel to the multiple inheritance test case below, the wx method gets called instead of the base import wx class Base: def __init__(self, x): self.x = 1 def speak(self, timeout): raise NotImplementedError class Agg(Base): pass class Wx(Base, wx.Panel): def __init__(self, x): Base.__init__(self, x) def speak(self, timeout): print 'wx' class WXAgg(Agg,Wx): pass wxagg = WXAgg('hi') wxagg.speak(timeout=1) Is this platform specific? I am seein this on os x w/ my versions but am curious to know if it is consistent. God help us all. One possibility is that since wx.Panel implemented __getattribute__, it may be screwing up the python implementation of multiple inheritance if it depends on getattr, eg I found the following on __getattribute__: __getattribute__( self, name) Called unconditionally to implement attribute accesses for instances of the class. If the class also defines __getattr__, it will never be called (unless called explicitly). This method should return the (computed) attribute value or raise an AttributeError exception. In order to avoid infinite recursion in this method, its implementation should always call the base class method with the same name to access any attributes it needs, for example, "object.__getattribute__(self, name)". """ Just grasping at straws here... JDH ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel