Skip to content

Instantly share code, notes, and snippets.

@pocc
Created July 22, 2018 07:18
Show Gist options
  • Save pocc/5feb74606c68381d5239150d1bf504c7 to your computer and use it in GitHub Desktop.
Save pocc/5feb74606c68381d5239150d1bf504c7 to your computer and use it in GitHub Desktop.
Playing around with Python Inheritance
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