To understand the difference between the two, you need to understand inheritance and how the interpreter handles class methods.
self
is a reference to the object instance for which you are currently performing the application.
super
allows you to access attributes (methods, members, etc) of an ancestor type. It is a reference to a class type, rather than a reference to an object instance.
When you call super().<something>
you are telling the interpreter to look for a code definition in one of the parent classes. This way you can call the constructor of your parent class for example or override an implementation from a parent class and add some logic to it.
When you use self
correctly (as in, you use that for the first argument in methods), this allows you to access other properties (methods, members, etc) for the instance you are currently handling.
The reason you use super
when writing the __init__
function, is that without it, whenever you call any method on self
, the interpreter will invoke any implementation defined for the top-most class type first. To tell the interpreter to skip it, you have to use super()
.