Skip to content

Instantly share code, notes, and snippets.

@pcote
Last active March 26, 2017 16:54
Show Gist options
  • Save pcote/c46b9354d3a8e7c9dec584edc5273492 to your computer and use it in GitHub Desktop.
Save pcote/c46b9354d3a8e7c9dec584edc5273492 to your computer and use it in GitHub Desktop.
class MyClass(object):
pass
ob = MyClass()
def say_stuff(self):
print("The say stuff message here is: {}\n\n".format(self.msg))
setattr(MyClass, "say_stuff", say_stuff)
setattr(ob, "msg", "Patched in message for patched in class")
ob.say_stuff()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment