Skip to content

Instantly share code, notes, and snippets.

@ianawilson
Last active December 12, 2015 03:39
Show Gist options
  • Save ianawilson/4708931 to your computer and use it in GitHub Desktop.
Save ianawilson/4708931 to your computer and use it in GitHub Desktop.
Plugging functions in python
class Klass:
def foo(self):
print 'foo'
a = Klass()
a.foo()
_old_foo = Klass.foo
def bar(self):
print 'bar'
Klass.foo = bar
a.foo()
Klass.foo = _old_foo
a.foo()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment