Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@pknowledge
Created September 16, 2018 23:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pknowledge/bd15d344bcc404097bc6d6e632156086 to your computer and use it in GitHub Desktop.
Save pknowledge/bd15d344bcc404097bc6d6e632156086 to your computer and use it in GitHub Desktop.
python Super Built in function Example
class Parent:
def __init__(self, name):
print('Parent __init__', name)
class Parent2:
def __init__(self, name):
print('Parent2 __init__', name)
class Child(Parent2, Parent):
def __init__(self):
print('Child __init__')
Parent2.__init__(self, 'max')
Parent.__init__(self, 'tom')
print('-------------------Example 1--------------------')
child = Child()
class Child2(Parent):
def __init__(self):
print('Child __init__')
super().__init__('max')
print('-------------------Example 2--------------------')
child2 = Child2()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment