Skip to content

Instantly share code, notes, and snippets.

@eguven
Created October 8, 2019 15:18
Show Gist options
  • Save eguven/71c3a041990de6abf9289cd3966fa16b to your computer and use it in GitHub Desktop.
Save eguven/71c3a041990de6abf9289cd3966fa16b to your computer and use it in GitHub Desktop.
Example for changing python module scope
import importlib
m = importlib.import_module('mypackage.mymodule')
def foo():
return 42
m.foo = foo
#
from mypackage.mymodule import foo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment