Created
September 16, 2018 23:56
-
-
Save pknowledge/bd15d344bcc404097bc6d6e632156086 to your computer and use it in GitHub Desktop.
python Super Built in function Example
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 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