Python Object-Oriented Python Inheritance Super-Duper!

Johnny Austen
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Johnny Austen
Python Development Techdegree Graduate 19,878 Points

Trying to understand exactly what super() does?

Hi, got a couple quick questions about super() if anyone can help!

1) So is super() only used when you want to override the init function from the parent class?

2) Why do you need to redefine def init (arguments) and then redefine them again (in this video on the next line) using super().init(arguments)?

1 Answer

Steven Parker
Steven Parker
204,018 Points

You would use "super" when you override any method and want to access the version in the parent.

The line with "super" on it is not a definition, it is calling the method of the parent. The arguments are being passed to the function instead of being declared as parameters as they are on the "def" line.