1

Is there any way to import a module from memory, for example, if I were to store a python module in a database, then query it, is there any way to import that string into the current local scope without writing it to disk? for example:

module in db (as string):

def lol(x):
    return x

accessing:

def import_into_this_func_scope():
    x= query_from_db()
    import x
    x.lol("hello world")
IT Ninja
  • 6,174
  • 10
  • 42
  • 65
  • why not save the module as a temp file and then add the module to the python path? The temp file should be cleaned up on next boot up. Is there something that is preventing you from writing a temp file? – Rusty Weber May 29 '13 at 17:20

0 Answers0