Created
July 30, 2013 18:32
-
-
Save RichardBarrell/6115512 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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