Skip to content

Instantly share code, notes, and snippets.

@jamesfe
Created October 7, 2015 19:01
Show Gist options
  • Select an option

  • Save jamesfe/e4db624d024beac3325c to your computer and use it in GitHub Desktop.

Select an option

Save jamesfe/e4db624d024beac3325c to your computer and use it in GitHub Desktop.
Python Class Behavior?
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