On Monday 27 September 2010, 21:17:35 Darren Dale wrote:
> On Mon, Sep 27, 2010 at 3:02 PM, Vicente Sole <s...@esrf.fr> wrote:
> > Hi Gerard,
> >
> > Quoting Gerard Vermeulen <gav...@gmail.com>:
> >>  Phil,
> >>
> >> when running the following code
> >>
> >> #!/usr/bin/env python
> >> # -*- coding: utf-8 -*-
> >>
> >> import PyQt4.Qt as Qt
> >>
> >> class MyWidget(Qt.QWidget):
> >>
> >>    def __init__(self, parent=None):
> >>        super(Qt.QWidget, self).__init__(parent)
> >
> > Just for my information, what is the difference between:
> >
> > super(Qt.QWidget, self).__init__(parent)
> >
> > and:
> >
> > Qt.QWidget.__init__(self, parent)
>
> The example should have read: "super(MyWidget,
> self).__init__(parent)", not "super(Qt.QWidget,
> self).__init__(parent)". In this example, there is no difference
> between the two syntaxes, but in cases involving multiple inheritance,
> super() returns a proxy that delegates calls to the appropriate
> superclass, as determined by the method resolution order. More here:
> http://docs.python.org/library/functions.html#super

...and you can't inherit from more then one QObject derived class because 
sip does not support multiple inheritance.

The major difference for the user is easier refactoring, as the parent class 
only needs to be mentioned once..

One downside of using super is, that it's only feasible for Python's new 
style classes.

Pete
_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Reply via email to