[PyQt] Bug in sip-4.11.1 and PyQt-4.7.7 ?
Hans-Peter Jansen
hpj at urpla.net
Mon Sep 27 20:59:19 BST 2010
On Monday 27 September 2010, 21:17:35 Darren Dale wrote:
> On Mon, Sep 27, 2010 at 3:02 PM, Vicente Sole <sole at esrf.fr> wrote:
> > Hi Gerard,
> >
> > Quoting Gerard Vermeulen <gav451 at 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
More information about the PyQt
mailing list