Skip to content

Instantly share code, notes, and snippets.

@Eugeny
Created April 19, 2011 16:46
Show Gist options
  • Save Eugeny/928774 to your computer and use it in GitHub Desktop.
Save Eugeny/928774 to your computer and use it in GitHub Desktop.
import types
class Target (object):
def A(self):
print 'in A'
def newfun(self):
print 'in B'
def add():
setattr(Target, 'B', types.MethodType(newfun, Target))
add()
c = Target()
c.A()
c.B()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment