Skip to content

Instantly share code, notes, and snippets.

@RichardBarrell
Created July 30, 2013 18:32
Show Gist options
  • Save RichardBarrell/6115512 to your computer and use it in GitHub Desktop.
Save RichardBarrell/6115512 to your computer and use it in GitHub Desktop.
import inspect
def marmoset_patch(old, new, extra_globals={}):
g = old.func_globals
g.update(extra_globals)
c = inspect.getsource(new)
exec c in g
old.func_code = g[new.__name__].func_code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment