It would be great if the Python Tutorial section on Classes and Inheritance (9. Classes — Python 3.13.1 documentation) could have an explanation of when and how to use super()
for initialization in derived classes, with examples if possible.
The function is only briefly mentioned in the next section.
Its docs (Built-in Functions — Python 3.13.1 documentation) are not really helpful for beginners to get started.
2 Likes
+1. I’d also like the example to show the ordering it uses when calling parents. Maybe even mention what happens with “diamond inheritance”.
1 Like
If I may, I have another request
The tutorial on classes does not seem to explain that/why every class method’s first argument is the instance (usually named self
).
The code examples all use it, but the first mention of self
in the text is in 9. Classes — Python 3.13.1 documentation and only regarding the naming convention.
2 Likes
At the end of the super()
function docs, there is a link to Raymond Hettinger’s blogpost with examples: Python’s super() considered super! | Deep Thoughts by Raymond Hettinger.