0

I understand the purpose of the super() function in Python, but I am a bit hazy on the details and keep having to look them up when I want to use it.

The problem is that most information about super() is either about Python 2, or about the differences between Python 2 and Python 3. This means that as a Python 3 user I always have to go on a bit of a wild goose chase learning how it used to work in the past before I can understand how it works now.

So, for the sake of myself and others, I thought it would be helpful to ask for a brief summary of how super() works in Python 3, without reference to the old Python 2 behaviour. I understand its use and purpose, at least at a basic level, but there is some syntactical magic associated with it, and I would like to understand exactly what happens when it is invoked.

N. Virgo
  • 7,970
  • 11
  • 44
  • 65
  • 1
    The point of this question is to have a canonical answer that explains how `super()` works in Python 3 **without assuming prior knowledge of how it works in Python 2**. The marked duplicates do not do this. They are examples of what I describe in my second paragraph. – N. Virgo Oct 29 '18 at 03:26
  • Just to note also that this is a general problem with fast-moving languages like Python and JavaScript. A lot of documentation and resources for Python 3 concentrate on how it's different from Python 2. If you're starting with Python 3 then this makes things difficult, because you always have to learn the Python 2 way first and then un-learn it. Stack Exchange would be a good resource for resolving this, if questions of the form "please explain this Python 3 feature without reference to Python 2" would be admitted. – N. Virgo Oct 29 '18 at 03:33

0 Answers0