Need to restart python in Terminal every time a change is made to script

前端 未结 5 642
南旧
南旧 2021-01-12 07:57

Every time I make a change to a python script I have to reload python and re-import the module. Please advise how I can modify my scripts and run then without having to rela

5条回答
  •  情话喂你
    2021-01-12 08:50

    I found a bypass online. Magic commands exist. It works like a charm for me. The Reload option didn't work for me. Got it from here and point 3 of this link.

    Basically all you have to do is the following: and changes you make are reflected automatically after you save.

    In [1]: %load_ext autoreload
    
    In [2]: %autoreload 2
    
    In [3]: Import MODULE
    
    In [4]: my_class = Module.class()
            my_class.printham()
    Out[4]: ham
    
    In [5]: #make changes to printham and save
    In [6]: my_class.printham() 
    Out[6]: hamlet
    

提交回复
热议问题