From b84cf169e50f8d747374d0f3e26f53f240496011 Mon Sep 17 00:00:00 2001 From: gaochenyi <32761974+gaochenyi@users.noreply.github.com> Date: Wed, 1 Nov 2023 14:29:44 +0800 Subject: [PATCH] Fix some typos --- oop.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/oop.md b/oop.md index 53f1cc82..179fdac8 100644 --- a/oop.md +++ b/oop.md @@ -169,7 +169,7 @@ To use inheritance, we specify the base class names in a tuple following the cla In contrast, if we have not defined an `__init__` method in a subclass, Python will call the constructor of the base class automatically. -While we could treat instances of `Teacher` or `Student` as we would an instance of `SchoolMember` and access the `tell` method of `SchoolMember` by simply typing `Teacher.tell` or `Student.tell`, we instead define another `tell` method in each subclass (using the `tell` method of `SchoolMember` for part of it) to tailor it for that subclass. Because we have done this, when we write `Teacher.tell` Python uses the `tell` method for that subclass vs the superclass. However, if we did not have a `tell` method in the subclass, Python would use the `tell` method in the superclass. Python always starts looking for methods in the actual subclass type first, and if it doesnÂ’t find anything, it starts looking at the methods in the subclassÂ’s base classes, one by one in the order they are specified in the tuple (here we only have 1 base class, but you can have multiple base classes) in the class definition. +While we could treat instances of `Teacher` or `Student` as we would an instance of `SchoolMember` and access the `tell` method of `SchoolMember` by simply typing `Teacher.tell` or `Student.tell`, we instead define another `tell` method in each subclass (using the `tell` method of `SchoolMember` for part of it) to tailor it for that subclass. Because we have done this, when we write `Teacher.tell` Python uses the `tell` method for that subclass vs the superclass. However, if we did not have a `tell` method in the subclass, Python would use the `tell` method in the superclass. Python always starts looking for methods in the actual subclass type first, and if it doesn't find anything, it starts looking at methods in the subclass's base classes, one by one in the order they are specified in the tuple (here we only have 1 base class, but you can have multiple base classes) in the class definition. A note on terminology - if more than one class is listed in the inheritance tuple, then it is called **multiple inheritance**.