Same module is being imported in different files

后端 未结 1 1093
野趣味
野趣味 2020-12-15 22:40

Is it a bad practice to do this:

In first.py:

import second
import mymodule

In second.py:

import mymodule


        
相关标签:
1条回答
  • 2020-12-15 22:56

    mymodule is only run once; every module that imports it shares the same copy. It's fine. Just be careful if you have any cyclic imports (A imports B imports A, or A imports B imports C ... imports A), because those can cause subtle initialization order problems and mess you up.

    0 讨论(0)
提交回复
热议问题