Test it out. Create a parent class with some attributes defined in the constructor. Do the same for the subclass. Now try to create an instance of the subclass setting each attribute, and check each attributes value. It should become apparent why you may want a reference to the parent class. Answer from Goingone on reddit.com
🌐
W3Schools
w3schools.com › python › ref_func_super.asp
Python super() Function
The super() function returns an object that represents the parent class. ... If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: [email protected] · If you want to report an error, or ...
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-super
Python super() - GeeksforGeeks
September 25, 2025 - In Python, the super() function is used to call methods from a parent (superclass) inside a child (subclass).
People also ask

Which is the best city in India for a programming course?
Some of the best cities where students can study at the top programming colleges in India are mentioned in the table below, along with the number of colleges in each city: Location No. of Colleges Maharashtra 140+ colleges Karnataka 70+ colleges Uttar Pradesh 60+ colleges West Bengal 45+ colleges Tamil Nadu 40+ colleges Gujarat 40+ colleges Haryana 35+ colleges Punjab 35+ colleges Disclaimer: This information is sourced from the official website and may vary.
🌐
shiksha.com
shiksha.com › home › it & software › programming › colleges in india
Super() Function in Python
Is there any scope in computer programming or app development?
Yes, programming languages like C, C+, Java, Kotlin, Swift, etc. Are typically used to create apps. The app is becoming more important and useful for everyone's lives, so it has a very broad scope. Every business and company needs software to use for some tasks of their company.
🌐
shiksha.com
shiksha.com › home › it & software › programming › colleges in india
Super() Function in Python
How many programming colleges are there in India?
There are more than 930+ Programming colleges in India where students can study. Some of the top colleges where students can learn programming include Amity University, MIT-WPU, Parul University, IIT Madras, IIT Kanpur, School of Engineering and Technology, Coding Ninjas, IIT Bombay, K J Somaiya School of Engineering, IIT Delhi, etc.
🌐
shiksha.com
shiksha.com › home › it & software › programming › colleges in india
Super() Function in Python
🌐
Programiz
programiz.com › python-programming › methods › built-in › super
Python super()
... The super() builtin returns a proxy object (temporary object of the superclass) that allows us to access methods of the base class. class Animal(object): def __init__(self, animal_type): print('Animal Type:', animal_type) class Mammal(Animal): def __init__(self):
🌐
Reddit
reddit.com › r/learnpython › what is the point of the super function in python classes?
r/learnpython on Reddit: What is the point of the super function in Python classes?
December 1, 2022 -

I’m taking a Python course and I’m having a hard time wrapping my head around it. If you use inheritance, then you already should have access to the parent classes’ methods and attributes. If the point of the super function is to give you access to the parent classes methods, isn’t this completely redundant?

Top answer
1 of 7
7
It can be a bit more complex than that. In a simple case, if, say, B inherits from A, but you want to use some of B's methods, you may think, "I can just call those methods myself - I know what they are." Ie: class B(A): def __init__(self, x, y): A.__init__(self, x) self.y = y def foo(self): x = A.foo(self) # Start with A's foo() result return do_something_extra(x) # And modify it slightly And this'll work fine - and is exactly what people did before super was added. And it seems like all you need: you obviously know what methods to call - you just wrote A in the inheritance tree right above it, so you know you need to call A.__init__, so why this extra super function? However, there are cases where this breaks. Consider multiple inheritance. Eg. suppose we have parents A and B, and C inherits from both. We obviously need to call A and B's __init__ method in C. Now, this initially seems simple enough. Just call both. Ie: class C(A, B): def __init__(self): A.__init__(self) B.__init__(self) No problem. But now suppose both A and B inherit from another class, X (ie a diamond inheritance pattern). Ie. A is defined with: class A(X): def __init__(self): X.__init__(self) And B is the same. Now our code has a problem - we end up calling X.__init__() twice for the same object. This is potentially a bug if X's initialiser triggers some side effect (eg. maybe it increments a counter for how many instances exist - now it'll be doublecounting the same object). And we'll also be calling it after A (it's subclass's) __init__ has completed so it could end up undoing some of the initialisation its child class did by resetting members etc. We really need this to be called only once, and before the rest of A and B's __init__ are finished. super() is designed to solve issues like this, and to do so, the notion of "parent" kind of breaks down a little. Instead, we define a single path through the tree (called the method resolution order). Calling super() in C gets you A, but then when A calls super(), it gets you B - even though B isn't anywhere in A's inheritance hierarchy, and then B's call to super() finally gets X. So we zig-zag through the inheritance hiererchy to get a single path that respects parent ordering etc. There's no way you sensibly can do this without super(), because B can't really know that sometimes A will be involved depending on its child class, and C, which does know, can't really easily monkey with what B does in its initialiser. Hence you need something more dynamic that can alter the resolution order depending on what class is actually being constructed. You can see this path via the __mro__ attribute on your class. Ie doing C.__mro__ in the above example would give you: (__main__.C, __main__.A, __main__.B, __main__.X, object)
2 of 7
5
Test it out. Create a parent class with some attributes defined in the constructor. Do the same for the subclass. Now try to create an instance of the subclass setting each attribute, and check each attributes value. It should become apparent why you may want a reference to the parent class.
🌐
Educative
educative.io › answers › what-is-super-in-python
What is super() in Python?
The super() function in Python makes class inheritance more manageable and extensible. The function returns a temporary object that allows reference to a parent class by the keyword super.
Top answer
1 of 7
2374

super() lets you avoid referring to the base class explicitly, which can be nice. But the main advantage comes with multiple inheritance, where all sorts of fun stuff can happen. See the standard docs on super if you haven't already.

Note that the syntax changed in Python 3.0: you can just say super().__init__() instead of super(ChildB, self).__init__() which IMO is quite a bit nicer. The standard docs also refer to a guide to using super() which is quite explanatory.

2 of 7
1296

I'm trying to understand super()

The reason we use super is so that child classes that may be using cooperative multiple inheritance will call the correct next parent class function in the Method Resolution Order (MRO).

In Python 3, we can call it like this:

class ChildB(Base):
    def __init__(self):
        super().__init__()

In Python 2, we were required to call super like this with the defining class's name and self, but we'll avoid this from now on because it's redundant, slower (due to the name lookups), and more verbose (so update your Python if you haven't already!):

        super(ChildB, self).__init__()

Without super, you are limited in your ability to use multiple inheritance because you hard-wire the next parent's call:

        Base.__init__(self) # Avoid this.

I further explain below.

"What difference is there actually in this code?:"

class ChildA(Base):
    def __init__(self):
        Base.__init__(self)

class ChildB(Base):
    def __init__(self):
        super().__init__()

The primary difference in this code is that in ChildB you get a layer of indirection in the __init__ with super, which uses the class in which it is defined to determine the next class's __init__ to look up in the MRO.

I illustrate this difference in an answer at the canonical question, How to use 'super' in Python?, which demonstrates dependency injection and cooperative multiple inheritance.

If Python didn't have super

Here's code that's actually closely equivalent to super (how it's implemented in C, minus some checking and fallback behavior, and translated to Python):

class ChildB(Base):
    def __init__(self):
        mro = type(self).mro()
        check_next = mro.index(ChildB) + 1 # next after *this* class.
        while check_next < len(mro):
            next_class = mro[check_next]
            if '__init__' in next_class.__dict__:
                next_class.__init__(self)
                break
            check_next += 1

Written a little more like native Python:

class ChildB(Base):
    def __init__(self):
        mro = type(self).mro()
        for next_class in mro[mro.index(ChildB) + 1:]: # slice to end
            if hasattr(next_class, '__init__'):
                next_class.__init__(self)
                break

If we didn't have the super object, we'd have to write this manual code everywhere (or recreate it!) to ensure that we call the proper next method in the Method Resolution Order!

How does super do this in Python 3 without being told explicitly which class and instance from the method it was called from?

It gets the calling stack frame, and finds the class (implicitly stored as a local free variable, __class__, making the calling function a closure over the class) and the first argument to that function, which should be the instance or class that informs it which Method Resolution Order (MRO) to use.

Since it requires that first argument for the MRO, using super with static methods is impossible as they do not have access to the MRO of the class from which they are called.

Criticisms of other answers:

super() lets you avoid referring to the base class explicitly, which can be nice. . But the main advantage comes with multiple inheritance, where all sorts of fun stuff can happen. See the standard docs on super if you haven't already.

It's rather hand-wavey and doesn't tell us much, but the point of super is not to avoid writing the parent class. The point is to ensure that the next method in line in the method resolution order (MRO) is called. This becomes important in multiple inheritance.

I'll explain here.

class Base(object):
    def __init__(self):
        print("Base init'ed")

class ChildA(Base):
    def __init__(self):
        print("ChildA init'ed")
        Base.__init__(self)

class ChildB(Base):
    def __init__(self):
        print("ChildB init'ed")
        super().__init__()

And let's create a dependency that we want to be called after the Child:

class UserDependency(Base):
    def __init__(self):
        print("UserDependency init'ed")
        super().__init__()

Now remember, ChildB uses super, ChildA does not:

class UserA(ChildA, UserDependency):
    def __init__(self):
        print("UserA init'ed")
        super().__init__()

class UserB(ChildB, UserDependency):
    def __init__(self):
        print("UserB init'ed")
        super().__init__()

And UserA does not call the UserDependency method:

>>> UserA()
UserA init'ed
ChildA init'ed
Base init'ed
<__main__.UserA object at 0x0000000003403BA8>

But UserB does in-fact call UserDependency because ChildB invokes super:

>>> UserB()
UserB init'ed
ChildB init'ed
UserDependency init'ed
Base init'ed
<__main__.UserB object at 0x0000000003403438>

Criticism for another answer

In no circumstance should you do the following, which another answer suggests, as you'll definitely get errors when you subclass ChildB:

super(self.__class__, self).__init__()  # DON'T DO THIS! EVER.

(That answer is not clever or particularly interesting, but in spite of direct criticism in the comments and over 17 downvotes, the answerer persisted in suggesting it until a kind editor fixed his problem.)

Explanation: Using self.__class__ as a substitute for explicitly passing the class by name in super() will lead to recursion. super lets us look up the next parent in the MRO (see the first section of this answer) for child classes. If we tell super we're in the child's method, it will then lookup the next method in line (probably this same one we are calling it from) resulting in recursion, causing either a logical failure (as in the answerer's example) or a RuntimeError when the maximum recursion depth is exceeded.

class Polygon(object):
    def __init__(self, id):
        self.id = id

class Rectangle(Polygon):
    def __init__(self, id, width, height):
        super(self.__class__, self).__init__(id)
        self.shape = (width, height)

class Square(Rectangle):
    pass

>>> Square('a', 10, 10)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 3, in __init__
TypeError: __init__() missing 2 required positional arguments: 'width' and 'height'

Python 3's new super() calling method with no arguments fortunately allows us to sidestep this issue.

🌐
Shiksha
shiksha.com › home › it & software › programming › colleges in india
Super() Function in Python
July 4, 2025 - Programmers often use an IDE, which allows them to create, edit, and test code. Without coding softwares are not imaginable. In India IT companies have lots of opportunities for good programmers. Languages like R, Python, JAVA, PHP and UNIX are some of the high demand programming languages.
Find elsewhere
🌐
Real Python
realpython.com › ref › builtin-functions › super
super() | Python’s Built-in Functions – Real Python
The built-in super() function provides a way to access methods from a superclass from within a subclass.
🌐
Medium
medium.com › @thapavishal117 › super-in-python-b8c818782803
super() in python. In Python, the super() function is used… | by Vishal Thapa | Medium
October 5, 2023 - In Python, the super() function is used to call a method from a parent class (also called a superclass or base class) within a subclass. It allows you to access and utilize the methods and attributes defined in the parent class while customizing ...
🌐
DigitalOcean
digitalocean.com › community › tutorials › python-super
Python super() - Python 3 super() | DigitalOcean
August 3, 2022 - As we have stated previously that Python super() function allows us to refer the superclass implicitly. But in the case of multi-level inheritances which class will it refer? Well, Python super() will always refer the immediate superclass. Also Python super() function not only can refer the __init__() function but also can call all other function of the superclass.
Top answer
1 of 11
483

What's the difference?

SomeBaseClass.__init__(self) 

means to call SomeBaseClass's __init__. while

super().__init__()

means to call a bound __init__ from the parent class that follows SomeBaseClass's child class (the one that defines this method) in the instance's Method Resolution Order (MRO).

If the instance is a subclass of this child class, there may be a different parent that comes next in the MRO.

Explained simply

When you write a class, you want other classes to be able to use it. super() makes it easier for other classes to use the class you're writing.

As Bob Martin says, a good architecture allows you to postpone decision making as long as possible.

super() can enable that sort of architecture.

When another class subclasses the class you wrote, it could also be inheriting from other classes. And those classes could have an __init__ that comes after this __init__ based on the ordering of the classes for method resolution.

Without super you would likely hard-code the parent of the class you're writing (like the example does). This would mean that you would not call the next __init__ in the MRO, and you would thus not get to reuse the code in it.

If you're writing your own code for personal use, you may not care about this distinction. But if you want others to use your code, using super is one thing that allows greater flexibility for users of the code.

Python 2 versus 3

This works in Python 2 and 3:

super(Child, self).__init__()

This only works in Python 3:

super().__init__()

It works with no arguments by moving up in the stack frame and getting the first argument to the method (usually self for an instance method or cls for a class method - but could be other names) and finding the class (e.g. Child) in the free variables (it is looked up with the name __class__ as a free closure variable in the method).

I used to prefer to demonstrate the cross-compatible way of using super, but now that Python 2 is largely deprecated, I will demonstrate the Python 3 way of doing things, that is, calling super with no arguments.

Indirection with Forward Compatibility

What does it give you? For single inheritance, the examples from the question are practically identical from a static analysis point of view. However, using super gives you a layer of indirection with forward compatibility.

Forward compatibility is very important to seasoned developers. You want your code to keep working with minimal changes as you change it. When you look at your revision history, you want to see precisely what changed when.

You may start off with single inheritance, but if you decide to add another base class, you only have to change the line with the bases - if the bases change in a class you inherit from (say a mixin is added) you'd change nothing in this class.

In Python 2, getting the arguments to super and the correct method arguments right can be a little confusing, so I suggest using the Python 3 only method of calling it.

If you know you're using super correctly with single inheritance, that makes debugging less difficult going forward.

Dependency Injection

Other people can use your code and inject parents into the method resolution:

class SomeBaseClass(object):
    def __init__(self):
        print('SomeBaseClass.__init__(self) called')
    
class UnsuperChild(SomeBaseClass):
    def __init__(self):
        print('UnsuperChild.__init__(self) called')
        SomeBaseClass.__init__(self)
    
class SuperChild(SomeBaseClass):
    def __init__(self):
        print('SuperChild.__init__(self) called')
        super().__init__()

Say you add another class to your object, and want to inject a class between Foo and Bar (for testing or some other reason):

class InjectMe(SomeBaseClass):
    def __init__(self):
        print('InjectMe.__init__(self) called')
        super().__init__()

class UnsuperInjector(UnsuperChild, InjectMe): pass

class SuperInjector(SuperChild, InjectMe): pass

Using the un-super child fails to inject the dependency because the child you're using has hard-coded the method to be called after its own:

>>> o = UnsuperInjector()
UnsuperChild.__init__(self) called
SomeBaseClass.__init__(self) called

However, the class with the child that uses super can correctly inject the dependency:

>>> o2 = SuperInjector()
SuperChild.__init__(self) called
InjectMe.__init__(self) called
SomeBaseClass.__init__(self) called

Addressing a comment

Why in the world would this be useful?

Python linearizes a complicated inheritance tree via the C3 linearization algorithm to create a Method Resolution Order (MRO).

We want methods to be looked up in that order.

For a method defined in a parent to find the next one in that order without super, it would have to

  1. get the mro from the instance's type
  2. look for the type that defines the method
  3. find the next type with the method
  4. bind that method and call it with the expected arguments

The UnsuperChild should not have access to InjectMe. Why isn't the conclusion "Always avoid using super"? What am I missing here?

The UnsuperChild does not have access to InjectMe. It is the UnsuperInjector that has access to InjectMe - and yet cannot call that class's method from the method it inherits from UnsuperChild.

Both Child classes intend to call a method by the same name that comes next in the MRO, which might be another class it was not aware of when it was created.

The one without super hard-codes its parent's method - thus is has restricted the behavior of its method, and subclasses cannot inject functionality in the call chain.

The one with super has greater flexibility. The call chain for the methods can be intercepted and functionality injected.

You may not need that functionality, but subclassers of your code may.

Conclusion

Always use super to reference the parent class instead of hard-coding it.

What you intend is to reference the parent class that is next-in-line, not specifically the one you see the child inheriting from.

Not using super can put unnecessary constraints on users of your code.

2 of 11
357

The benefits of super() in single-inheritance are minimal -- mostly, you don't have to hard-code the name of the base class into every method that uses its parent methods.

However, it's almost impossible to use multiple-inheritance without super(). This includes common idioms like mixins, interfaces, abstract classes, etc. This extends to code that later extends yours. If somebody later wanted to write a class that extended Child and a mixin, their code would not work properly.

🌐
Board Infinity
boardinfinity.com › blog › python-super-keyword
Python super() keyword | Board Infinity
June 22, 2023 - In Python, the super() keyword is a built-in method that returns a proxy object (object of a superclass that is temporary). It allows us to access methods present in the base class.
🌐
Javatpoint
javatpoint.com › python-super-function
Python super() Function - Javatpoint
Python super() Function with python, tutorial, tkinter, button, overview, entry, checkbutton, canvas, frame, environment set-up, first python program, operators, etc.
🌐
Scaler
scaler.com › topics › super-in-python
super() in Python | super() Function in Python - Scaler Topics
April 8, 2022 - The super() function use the concept of MRO in the multiple inheritance. The super() function also takes two parameters i.e the immediate parent class name and the current object. Explore Scaler Topics Python Tutorial and enhance your Python skills with Reading Tracks and Challenges.
🌐
Python Reference
python-reference.readthedocs.io › en › latest › docs › functions › super.html
super — Python Reference (The Right Way) 0.1 documentation
Note that super() is implemented as part of the binding process for explicit dotted attribute lookups such as super().__getitem__(name). It does so by implementing its own __getattribute__() method for searching classes in a predictable order that supports cooperative multiple inheritance.
🌐
YouTube
youtube.com › bro code
SUPER() in Python explained! 🔴 - YouTube
# super() = Function used in a child class to call methods from a parent class (superclass).# Allows you to extend the functionality of the ...
Published   May 24, 2024
Views   1K
🌐
Quora
quora.com › What-is-the-use-of-a-super-keyword-in-Python
What is the use of a super keyword in Python? - Quora
Answer (1 of 2): super is used when you are using OOPs concept..During that to call the init of a main class from the base class you should use the super keyword
🌐
Sentry
sentry.io › sentry answers › python › `super()` and `__init__()` in python
`super()` and `__init__()` in Python | Sentry
In Python, super() is a built-in function used to call methods defined in the parent class. One of the advantages of inheritance in an object-oriented language like Python is avoiding code duplication.
🌐
FavTutor
favtutor.com › blogs › python-super-function
Python super() Function | With Code Examples
October 31, 2023 - In this case, the Animal class acts as the superclass, providing a common structure for different types of animals. Python's super keyword allows a subclass to invoke methods from its superclass. It is an essential element in ensuring that the ...
🌐
Medium
geekpython.medium.com › power-up-your-classes-using-super-in-python-bc844ab3d9aa
Power Up Your Classes Using Super() In Python | by Sachin Pal | Medium
February 23, 2023 - Inheritance is one of the four ... has an excellent function called super() that allows the parent class's attributes and methods to be fully accessible within a subclass....