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?
- Why is enum class preferred over plain enum?
- What’s the difference between a method and a function?
- How do I draw a grid onto a plot in Python?
- Importing modules from parent folder
- Getting a map() to return a list in Python 3.x
- Pandas how to use pd.cut()
- What is the difference between list and list[:] in python?
- Inheriting constructors
- How to Read .txt in Pandas
- Python command not working in command prompt
- How to pretty print nested dictionaries?
- Is there a linked list predefined library in Python?
- return, return None, and no return at all?
- What does [:-1] mean/do in python? [duplicate]
- What does .class mean in Java?
- How to stop/terminate a python script from running?
- ‘pip install’ fails for every package (“Could not find a version that satisfies the requirement”) [duplicate]
- TypeError: ‘_io.TextIOWrapper’ object is not subscriptable
- super(type, obj): obj must be an instance or subtype of type
- What does “hashable” mean in Pytho
- Python multiprocessing.Pool: AttributeError
- Installation of pygame with Anaconda
- Is there a Python equivalent of the C# null-coalescing operator?
- Python 3.6 import requests
- Tensorflow 2.0 – AttributeError: module ‘tensorflow’ has no attribute ‘Session’
- Python: Convert timedelta to int in a dataframe
- Can’t concat bytes to str
- How to create a flexible abstraction for WP_Query?
- Python with wordpress plugin
- OOP and WordPress shortcode
- Remove an action by extending class and replacing it
- Extend Woocommerce Widget Class – WC_Widget_Product_Categories