KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Possible Duplicate: Circular (or cyclic) imports in Python I have class B that imports and creates instances of class A. Class A needs reference to B in its contructor and so includes B. from a import A class B: def __init__(self): self.a = A() from b import B class A: def __init__(self, ref): assert isinstance(ref, B) self.ref = ref This doesn't work. The main file imports B and uses it... not. Something with the imports is wrong. Error from file a ImportError: cannot import name B
Tags (comma-separated)
Save Edits
Cancel