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.
Related Posts:
- What does ‘super’ do in Python? – difference between super().__init__() and explicit superclass __init__()
- Is it possible to make abstract classes in Python?
- What is the purpose of the word ‘self’?
- What is the difference between private and protected members of C++ classes?
- What does ‘super().__init__()’ mean in python 3.x?
- Are static class variables possible in Python?
- Python: How do I make a subclass from a superclass?
- Difference between ‘cls’ and ‘self’ in Python classes?
- How to implement a binary search tree in Python?
- Python function overloading
- super() fails with error: TypeError “argument 1 must be type, not classobj” when parent does not inherit from object
- C++ – No appropriate default constructor available
- How do you implement a class in C?
- What does the variable $this mean in PHP?
- What are data classes and how are they different from common classes?
- What __init__ and self do in Python?
- When should you use a class vs a struct in C++?
- Using two CSS classes on one element
- Difference between Inheritance and Composition
- How do I implement interfaces in python?
- How to assign multiple classes to an HTML container?
- Creating a static class with no instances
- C++ [Error] no matching function for call to
- How to assign multiple classes to an HTML container?
- Does Python have “private” variables in classes?
- What are metaclasses in Python?
- Separating class code into a header and cpp file
- AttributeError: ” object has no attribute ”
- Python calling method in class
- What is a mixin, and why are they useful?
- AttributeError: ‘datetime’ module has no attribute ‘strptime’
- How can I create a copy of an object in Python?
- How do you call an instance of a class in Python?
- Prefer composition over inheritance?
- Error “C++ requires a type specifier for all declarations whilst defining methods”
- What are the differences between struct and class in C++?
- What is the meaning of single and double underscore before an object name?
- List attributes of an object [duplicate]
- How to sort a list of objects based on an attribute of the objects?
- When should I use ‘self’ over ‘$this’?
- How to print instances of a class using print()?
- How to extend a class in python?
- Using __add__ operator with multiple arguments in Python
- How to call a parent class function from derived class function?
- How do I define string constants in C++?
- Meaning of @classmethod and @staticmethod for beginner?
- Meaning of @classmethod and @staticmethod for beginner?
- When should I be using classes in Python?
- C++ variable has initializer but incomplete type?
- When to use ‘raise NotImplementedError’?
- How can I create an object and add attributes to it?
- Accessing a class’ member variables in Python?
- Why do some classes require main methods and others do not?
- Inheritance and init method in Python
- Pass arguments to Constructor in VBA
- Why is there no multiple inheritance in Java, but implementing multiple interfaces is allowed?
- What is predicate in C++?
- Inheritance vs. Aggregation [closed]
- What’s wrong with overridable method calls in constructors?
- uml classdiagram constructor with parameters
- TypeError: module.__init__() takes at most 2 arguments (3 given)
- Does C have classes?
- Explaining Python’s ‘__enter__’ and ‘__exit__’
- What is a mixin, and why are they useful?
- “public” or “private” attribute in Python ? What is the best way?
- Here is some error with my .h file which show [Error] unterminated #ifndef when I include my class template in it
- Error: invalid use of member in static member function
- How can I design a class named allergy?
- SyntaxError: unexpected EOF while parsing
- How do I lowercase a string in Python?
- How do I copy a file in Python?
- How can I reverse a list in Python?
- Manually raising (throwing) an exception in Python
- How do I copy a file in Python?
- can’t multiply sequence by non-int of type ‘float’
- Difference between del, remove, and pop on lists
- How can I reverse a list in Python?
- How to use the pass statement
- How to use filter, map, and reduce in Python 3
- What does enumerate() mean?
- Searching the student-t distribution table for values using python
- How to declare an array in Python?
- Does Python have a ternary conditional operator?
- Use Gif Logo For Loading Screen In Kivy
- Praw & Discord.py: The bot keep sending the same meme. I want the bot to send different meme whenever it is asked
- Pig Latin Translator
- What is the difference between Python’s list methods append and extend?
- How can I make a time delay in Python? [duplicate]
- Python – TypeError: ‘int’ object is not iterable
- TypeError: ‘int’ object is not subscriptable
- sphinx.ext.autodoc: Keeping names of constants in signature
- are there dictionaries in javascript like python?
- How do you round UP a number?
- Understanding slice notation
- Iterating over dictionaries using ‘for’ loops
- How to define a two-dimensional array?
- how to sort pandas dataframe from one column
- Why am I seeing “TypeError: string indices must be integers”?
- Understanding the main method of python [duplicate]
- How do you round UP a number?