super has 2 args,
super(type, obj_of_type-or-subclass_of_type)
I understand how and why to use super with the 2nd arg being obj_of_type.
But I don’t understand the matter for the 2nd arg being subclass.
Anyone can show why and how?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You pass an object if you want to invoke an instance method. You pass a class if you want to invoke a class method.
The classic example for using
super()for class methods is with factory methods, where you want all the superclass factory methods to be called.“Invoking a superclass’s class methods in Python” has a real-world example.