<jupyter_start><jupyter_text>Python Reference - Inheritance**Author:** <NAME> Definitionone of the three pillars of object oriented programming Linkshttps://www.w3schools.com/python/python_inheritance.asp  syntaxto inherit from another class, simply import the class and put the class name of the parent class in parentheses behind the class name.  access the constructor of the parent class with **super().\_\_init\_\_(args...)**<jupyter_code>#----------------------------------------------------------------
class Lifeform:
    type: str
    gender: str

    def __init__(self, _type: str, _gender: str):
        self.type = _type
        self.gender = _gender
        
#----------------------------------------------------------------
# from ???.Lifeform import Lifeform <-- DO NOT FORGET TO IMPORT THE PARENT CLASS

class Human(Lifeform):

    name: str

    def __init__(self, _gender: str, _name: str):
        self.name = _name
        super().__init__(
            "Human",
            _gender)

L = Lifeform("Dog", "Male")
H = Human("Male", "Hans")

print(L.type)
print(L.gender)

print(H.type)
print(H.gender)
print(H.name)<jupyter_output>Dog
Male
Human
Male
Hans<jupyter_text>typeofthe python **typeof** method is **type(obj)**<jupyter_code>print(type(L))
print(type(H))<jupyter_output><class '__main__.Lifeform'>
<class '__main__.Human'><jupyter_text>isthe python **is** operator is **isinstance(obj, type)**<jupyter_code>print(isinstance(L, Lifeform))
print(isinstance(L, Human))
print(isinstance(H, Lifeform))
print(isinstance(H, Human))<jupyter_output>True
False
True
True
{'fraction_non_alphanumeric': 0.19974795211090107, 'fraction_numerical': 0.000630119722747322, 'mean_word_length': 3.0510204081632653, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 13, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '82767', 'license': 'MIT', 'n_tokens_mistral': 509, 'n_tokens_neox': 486, 'n_words': 130, 'path': 'OOP/Inheritance.ipynb', 'repo_name': 'Architect0711/PythonReference', 'size': '1595'}