Paul's Python CoursePPC

super()

Not met yet

super() reaches the parent class's methods for this same object. A subclass that writes its own __init__ replaces the parent's, so call super().__init__(...) to let the parent set up its part. In an overriding method, super().give_back(hours) reuses the parent's work so the subclass only adds what differs.

Try it

main.py

Output

Press Run and what your program prints shows up here.

Easy to get wrong

  • Thinks the parent's __init__ still runs when a subclass writes its own __init__.
  • Thinks super().method() calls the subclass's own version of the method again.

Where it comes up