Last active
June 1, 2016 00:37
-
-
Save sivabudh/a1ecaa94461f4187e152ce3ae60570aa to your computer and use it in GitHub Desktop.
Python 3 Inheritance (Code from `ptpython` REPL)
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
In [12]: class Base: | |
2 def __init__(self): | |
3 print("I'm base") | |
4 | |
5 class Child(Base): | |
6 def __init__(self): | |
7 print("I'm child") | |
8 | |
In [13]: c = Child() | |
I'm child | |
In [14]: class Base: | |
2 def __init__(self): | |
3 print("I'm base") | |
4 | |
5 class Child(Base): | |
6 def __init__(self): | |
7 super().__init__() | |
8 print("I'm child") | |
9 | |
In [15]: c = Child() | |
I'm base | |
I'm child |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment