Inheritance is a very important and strong function in connecting two classes. For example, after creating a class, the second class is based on the first one or need some functions from the first one. We can let the second class inherit the first one by writing:
class Second_One(First_One):
def __init__(self):
f().__init__(self)
f() is calling all methods in the first class. The advantage of inheritance is that I can only use self.XXX() instead of using First_One.XXX(), which makes my code much simpler obviously.
No comments:
Post a Comment