Skip to content

Instantly share code, notes, and snippets.

@cristianrasch
Created March 25, 2012 22:48
Show Gist options
  • Save cristianrasch/2200542 to your computer and use it in GitHub Desktop.
Save cristianrasch/2200542 to your computer and use it in GitHub Desktop.
Making fun of Python's OOP weirdness
#!/usr/bin/env python
class P(object):
def foo(self):
print "Called P's foo()"
# print "Called %s's foo()" % self.__class__.__name__
class C(P):
def foo(self):
# P.foo(self)
super(self.__class__, self).foo()
print "Called %s's foo()" % self.__class__.__name__
if __name__ == '__main__':
# P().foo()
C().foo()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment