So... I'm working on trying to move from basic Python to some GUI programming, using PyQt4. I'm looking at a couple different books and tutorials, and they each seem to have a slightly different way of kicking off the class definition.
One tutorial starts off the classes like so:
class Example(QtGui.QDialog):def __init__(self):super(Example, self).__init__()
Another book does it like this:
class Example(QtGui.QDialog):def __init__(self, parent=None):super(Example, self).__init__(parent)
And yet another does it this way:
class Example(QtGui.QDialog):def__init__(self, parent=None):QtGui.QWidget.__init__(self, parent)
I'm still trying to wrap my mind around classes and OOP and super()
and all... am I correct in thinking that the last line of the third example accomplishes more or less the same thing as the calls using super()
in the previous ones, by explicitly calling the base class directly? For relatively simple examples such as these, i.e. single inheritance, is there any real benefit or reason to use one way vs. the other? Finally... the second example passes parent
as an argument to super()
while the first does not... any guesses/explanations as to why/when/where that would be appropriate?