Created
October 7, 2015 19:01
-
-
Save jamesfe/e4db624d024beac3325c to your computer and use it in GitHub Desktop.
Python Class Behavior?
This file contains hidden or 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 a(object): | |
| def do_something(self): | |
| print("Something from A") | |
| class b(a): | |
| def do_something(self): | |
| print("Something from B (1)") | |
| super(self.__class__, self).do_something() | |
| print("Something from B (2)") | |
| class c(b): | |
| pass | |
| new_parent = a() | |
| new_parent.do_something() | |
| new_child = b() | |
| new_child.do_something() | |
| new_new_child = c() | |
| new_new_child.do_something() # what does this print? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment