Tag Archives: TypeError: super() takes at least 1 argument (0 given)

Python Typeerror: super() takes at least 1 argument (0 given) error in Python

Typeerror: super() takes at least 1 argument (0 given) error occurred when writing inheritance subclass

Source code (perfect to run in python3)

class Example(QWidget):
    
    def __init__(self):
        super().__init__()
        
        self.initUI() #Interface drawing is given to the InitUi method
        
        

The reason is super ()__ init__() Function is supported in python3, which is correct, but it will cause problems in python2

If you want to inherit the construction method of the parent class in Python 2, you need to pass in the super parameter: Super (example, self)__ init__();

In python2, it should be written as follows:

class Example(QWidget):
    
    def __init__(self):
        super(Example,self).__init__()
        
        self.initUI() #Interface drawing is given to the InitUi method