0

What does super() do?

Hey guys, at the moment I'm working with Python and PyQT and I found that some people are using the super() command. So my question is what does it do? Class programm(QDialog): def __init__(self): super(programm, self).__init__() <---- loadUi('path', self)

9th Apr 2019, 4:39 PM
Talha Hameed
Talha Hameed - avatar
1 Respuesta
+ 2
With super() you invoke the class from which you inherit. That can for example be useful when your derived class constructor takes more arguments than the base constructor. You overwrite __init__ with the higher number of args, then from inside there you call super().__init__() with the number of args mommy class can handle. Like this you don't have to rewrite that code. The additional args you treat manually after that.
9th Apr 2019, 4:44 PM
HonFu
HonFu - avatar