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

前端 未结 5 637
南旧
南旧 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:58

    You can use reload to re-import a module. I use it frequently when using the interactive mode to debug code.

    However, from a higher level, I would be hesitant to use that in a production version of a program. Unless you will have very strict control over how sub-modules are changing, it would not be hard to have the reloaded module change in some way that breaks your program. Unless your program really needs 100% up-time, it would make sense to stop it and start it again when there is some kind of version change.

提交回复
热议问题