D
D
Deleting Account2020-04-24 17:14:07
Python
Deleting Account, 2020-04-24 17:14:07

Why is super used here if the class only inherits from object?

Why is super used here if the class is inherited from object?
Here is the code:

class Container(object):

    def __init__(self):
        super(Container, self).__init__()

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Pankov, 2020-04-24
@Andriy_Kosmenyuk

Well, strictly speaking, there is no special need. This is done, for example, if in the future they are going to change the base class.
But if your __init__ is completely empty and there is nothing but super, then it is completely useless.
In the third python, by the way, this is already possible:

class Container():
    def __init__(self):
        super().__init__()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question