So I know how to avoid this pitfall, what does a circular import look like from a model to a view and view to model?
所以我知道如何避免这个陷阱,从模型到视图和视图模型的循环导入是什么样的?
Also what would be a solution to the example given?
对于给出的例子,还有什么解决方案?
1 个解决方案
#1
0
Import the module, not the name. Don't attempt to use the name until it has been defined.
导入模块,而不是名称。在定义名称之前,请勿尝试使用该名称。
import foo
...
...
import bar
def baz():
bar.quux
#1
0
Import the module, not the name. Don't attempt to use the name until it has been defined.
导入模块,而不是名称。在定义名称之前,请勿尝试使用该名称。
import foo
...
...
import bar
def baz():
bar.quux