Skip to content

Instantly share code, notes, and snippets.

@sivabudh
Last active June 1, 2016 00:37
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 sivabudh/a1ecaa94461f4187e152ce3ae60570aa to your computer and use it in GitHub Desktop.
Save sivabudh/a1ecaa94461f4187e152ce3ae60570aa to your computer and use it in GitHub Desktop.
Python 3 Inheritance (Code from `ptpython` REPL)
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