Prevent Python from caching the imported modules

后端 未结 8 1706
误落风尘
误落风尘 2020-11-28 07:40

While developing a largeish project (split in several files and folders) in Python with IPython, I run into the trouble of cached imported modules.

The problem is th

8条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-28 08:01

    Quitting and restarting the interpreter is the best solution. Any sort of live reloading or no-caching strategy will not work seamlessly because objects from no-longer-existing modules can exist and because modules sometimes store state and because even if your use case really does allow hot reloading it's too complicated to think about to be worth it.

提交回复
热议问题