super()
is used to call a base class method that is redefined in the derived class. If your class were defining append()
and popleft()
methods extending their behavior, it would be reasonable to use super()
inside append()
and popleft()
. However, your example redefines nothing from deque
, so there is no need for super()
.
The following example shows when super()
is used:
class Queue(deque):
def append(self, a):
# Now you explicitly call a method from base class
# Otherwise you will make a recursive call
super(Queue, self).append(a)
print "Append!!!"
However, in case of multiple inheritance what super()
does is more complicated than just allowing to call a method from base class. Detailed understanding requires understanding MRO (method resolution order). As a result, even in the example above it is usually better to write:
class Queue(deque):
def append(self, a):
# Now you explicitly call a method from base class
# Otherwise you will make a recursive call
deque.append(self, a)
print "Append!!!"