Reload is effectively deprecated in 2.x and removed in 3.x, so I recommend not using it.

Deleting an entry from sys.modules should force recreation with an import. Just make sure all other references are also gone so that the module object can be deleted.

The following shows how to import by name in string and globally from within a function.

def f():
    global itertools
    itertools = __import__('itertools')

f()
print(itertools) # 3.1

#<module 'itertools' (built-in)>

Terry Jan Reedy

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to