What is the difference between super(A,self).__init__() and super().__init__()?

super(A,self).__init__()You can ensure that the parent class constructor of class A is called.

Instead super().__init_()of explicitly specifying the current class and instance, it is automatically inferred from the context of the call.

Single inheritance makes no difference.
The main difference is when there is multiple inheritance. The subclass can specify which parent class to inherit.

Guess you like

Origin blog.csdn.net/Yonggie/article/details/130685329