What is the purpose of using python `super() `, inside `__init__ ` other than the inheritance?
Question: I found this simple program in a Youtube tutorial which is used QtSide modules
with python. Basically what it does is connect `QLineEdit` to a
`QTextBrowser`. As you can see below, the entire program handled by single
class. I have basic idea of super() function which is used in multiple
inheritance. So here, I don't understand what `super(Form,
self).__init__(parent)` statement does. I tried running the same program after
commenting that statement which produced below error message.

Error:

    
    
    Traceback (most recent call last):
      File "/home/dazz/Projects/PycharmProjects/FirstTutorial/a2_gui.py", line 35, in <module>
        form = Form()
      File "/home/dazz/Projects/PycharmProjects/FirstTutorial/a2_gui.py", line 17, in __init__
        self.setLayout(layout)
    RuntimeError: '__init__' method of object's base class (Form) not called.
    

Program code:

    
    
    import sys
    from PySide.QtCore import *
    from PySide.QtGui import *
    
    
    class Form(QDialog):
        def __init__(self, parent=None):
            super(Form, self).__init__(parent)
    
            self.browser = QTextBrowser()
            self.lineEdit = QLineEdit()
    
    
            layout = QVBoxLayout()
            layout.addWidget(self.browser)
            layout.addWidget(self.lineEdit)
            self.setLayout(layout)
    
            self.lineEdit.returnPressed.connect(self.update_ui)
            self.setWindowTitle('Calculate')
    
        def update_ui(self):
            try:
                text = self.lineEdit.text()
                self.browser.append('%s = %s' % (text, eval(text)))
                self.lineEdit.selectAll()
    
            except:
                self.browser.append('%s is invalid!' % text)
    
    app = QApplication(sys.argv)
    form = Form()
    form.show()
    app.exec_()
    

Here, what is the use of `super()`? I found a
[question](http://stackoverflow.com/questions/15131282/about-the-super-
function) which may related to this. But it's not clear to me.


Answer: `super()` is used is inheritance, multiple or otherwise, to call methods that
may have been overridden in the current class.

Here `super()` is used to call the original `__init__` method defined for
`QDialog` or a parent class of that. Not calling the original probably will
have consequences as that original method does work you don't want to have to
replicate in your own `__init__` method.

`super()` makes multiple inheritance easier and more flexible to deal with,
but it is not _just_ for multiple inheritance.

