Reply To: How to reload a python module in same program ?

Home Forums Python Programming How to reload a python module in same program ? Reply To: How to reload a python module in same program ?

#1961
Humble
Keymaster

The builtin python function called ‘reload’ can be used to reload a module inside the same program.

>>>> reload.__doc__
'reload(module) -> module\n\nReload the module.  The module must have been successfully imported before.'
>>> 

For ex:

>>>> import os
>>> os
<module 'os' from '/usr/lib64/python2.7/os.pyc'>
>>> reload(os)
<module 'os' from '/usr/lib64/python2.7/os.pyc'>
>>> os