What is the use of super with arguments?

Question:

super() is a function in python used to acces members of a super class but sometimes it takes some arguments, what does does super with arguments do.

If either takes a class, a class and object or two classes other than no argument

What is the purpose of each? Where are they use

Asked By: Supergamer

||

Answers:

The two-argument form is the standard. The object specifies which MRO to search, the type specifies where to start looking in the MRO.

Almost always, you want to use the type of the current class, and you want to use the method’s self argument as the object, so Python is set up to "default" to these values if you pass no arguments. (In Python 2, you were required to provide arguments explicitly; Python 3 added the feature of inferring the commonly used arguments when none were given.)

If you pass one argument, only the current type is used; no object is implied, and you get an "unbound" instance of super. (Uses cases for such an object are rare.)

Answered By: chepner
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.