don't understand MRO
tjreedy at udel.edu
Thu Jun 23 19:22:58 CEST 2005
"Uwe Mayer" <merkosh at hadiko.de> wrote in message
news:d9eluf$ojc$1 at news2.rz.uni-karlsruhe.de...
> I have a subclassed PyQt class:
> class Node(object):
> def move(self, x,y): pass
> class CRhomb(QCanvasPolygon, Node): pass
> $ python
> [<class '__main__.CRhomb'>, <class 'qtcanvas.QCanvasPolygon'>, <class
> 'qtcanvas.QCanvasPolygonalItem'>, <class 'qtcanvas.QCanvasItem'>, <class
> 'qt.Qt'>, <type 'sip.wrapper'>, <class '__main__.Node'>, <type 'object'>]
For those who don't know, 'mro' stands for 'method resolution order'. The
method returns a list of classes (all except the first are base or super
classes of the first) in the order in which their dictionaries are searched
for method (or other attribute) names.
>>>> a = CRhomb()
> This executes also Node.move(a, 1,2)
In the absence of other information, I would presume that none of the other
classes have a move() method.
> Because even QCanvasItem.move delegates the call to the derived object?
> qt.Qt does not have a move() method... how does it get passed on to Node?
Are you sure that QCanvasItem has a move method? What results from
>>> print qtcanvas.QCanvasItem.move # ?
If so, I would need to see its code to try to answer.
Terry J. Reedy
More information about the Python-list