Reloading a changed python file in emacs python shell

后端 未结 3 1866
长情又很酷
长情又很酷 2021-01-02 16:19

In the emacs Python shell (I\'m running 2.* Python) I am importing a .py file I\'m working with and testing the code. If I change the code however I\'m not sure how to impor

3条回答
  •  猫巷女王i
    2021-01-02 17:18

    After looking at this issue for quite an extensive amount of time, I came to the conclusion that the best solution to implement is, either based on an initialisation file of your python interpreter (ipython for exemple), or using the python build-in module "imp" and its function "reload". For instance at the beginning of your code:

    import my_module
    import imp
    imp.reload(my_module)
    
    #your code
    

    This solution came to me from this page: https://emacs.stackexchange.com/questions/13476/how-to-force-a-python-shell-to-re-import-modules-when-running-a-buffer

提交回复
热议问题