Introduction

This page goes over inheritance of object between classes in Python. This is a big part of OOP and making reusable code.

super().__init__()

Notes

Links

Documentation

Built-in Functions

General

Python super() Function

Supercharge Your Classes With Python super() – Real Python

Python’s super() considered super!

Ex.: My First Example

class SuperClass:

    def __init__(self, money, hourly):
        self.money = money
        self.hourly = hourly

    def show_stats(self):
        return print('Money is {} and your hourly is {}'.format(self.money, self.hourly))

class SubClass(SuperClass):

    def __init__(self, money, hourly):
        super().__init__(money, hourly)

    def yea(self):
        return SuperClass.show_stats(self)

S = SubClass('$300', '$50500')
S.yea()

Seems to do the same thing as Ex. 1, but at least I wrote it myself. I am still now 100% what it does, other than inheriting objects from another class to then use in the subclass, but I can see how this can be useful. I am going to see if I can use this in my EP 425 final project (see EP 425 Semester Project and Project Code Notes)

My Analysis of the code:

Sources

General

Python Class Inheritance: A Guide to Reusable Code - Codefather