[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Re: Importing v reloading modules modules

Terry Reedy

3/19/2010 6:02:00 PM

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