ImportError: Cannot import name X

前端 未结 16 1221
隐瞒了意图╮
隐瞒了意图╮ 2020-11-22 04:33

I have four different files named: main, vector, entity and physics. I will not post all the code, just the imports, because I think that\'s where the error is. (If you want

16条回答
  •  鱼传尺愫
    2020-11-22 04:59

    While you should definitely avoid circular dependencies, you can defer imports in python.

    for example:

    import SomeModule
    
    def someFunction(arg):
        from some.dependency import DependentClass
    

    this ( at least in some instances ) will circumvent the error.

提交回复
热议问题