How to reload a python module in same program ?

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

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #1929 Reply
    Humble
    Keymaster

    Do you guys know how to reload a module inside the same python program, so that it will pick the new changes?

    #1961 Reply
    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
    
Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: How to reload a python module in same program ?
Your information: