Python: Alternatives to pickling a module

前端 未结 2 865
盖世英雄少女心
盖世英雄少女心 2021-01-14 17:49

I am working on my program, GarlicSim, in which a user creates a simulation, then he is able to manipulate it as he desires, and then he can save it to file.

I recen

2条回答
  •  轮回少年
    2021-01-14 18:45

    If the project somehow has a reference to a module with stuff you need, it sounds like you might want to refactor the use of that module into a class within the module. This is often better anyway, because the use of a module for stuff smells of a big fat global. In my experience, such an application structure will only lead to trouble.

    (Of course the quick way out is to save the module's dict instead of the module itself.)

提交回复
热议问题