How to reload python module imported using `from module import *`

前端 未结 8 1942
挽巷
挽巷 2020-12-02 14:12

I saw in this useful Q&A that one can use reload(whatever_module) or, in Python 3, imp.reload(whatever_module).

My question is, what if

相关标签:
8条回答
  • 2020-12-02 14:55

    for python 3.7 :

    from importlib import reload #import function "reload"
    import YourModule #import your any modules
    reload(YourModule) #reload your module
    

    Reload function can be called from your own function

    def yourFunc():
       reload(YourModule)
    
    0 讨论(0)
  • 2020-12-02 15:03
    import re
    
    for mod in sys.modules.values():
        if re.search('name', str(mod)):
            reload(mod)
    
    0 讨论(0)
提交回复
热议问题