Created
July 22, 2018 07:18
-
-
Save pocc/5feb74606c68381d5239150d1bf504c7 to your computer and use it in GitHub Desktop.
Playing around with Python Inheritance
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class First(object): | |
def __init__(self): | |
super(First, self).__init__() | |
print("first") | |
def print_b(self): | |
print('b') | |
class Second(First): | |
def __init__(self): | |
super(Second, self).__init__() | |
print("second") | |
self.one = First() | |
def print_a(self): | |
print('a') | |
self.one.print_b() | |
class Third(Second): | |
def __init__(self): | |
super(Third, self).__init__() | |
print("third") | |
self.two = Second() | |
A = Third() | |
A.two.one.print_b() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment