Possible Duplicate:
Python mutually dependent classes (circular dependencies)
I have 2 class in the same module/file, and they use one another.
class ClassA:
x = ClassB()
class ClassB:
x = ClassA()
ClassA would have a problem since the declaration of ClassB is after ClassA, hence ClassB is not found.
How do I solve this? Can I somehow import ClassB?
Update: My bad. The example above has a circular reference, and that disgusted many people.. Let me try again:
class ClassA:
x = 1
y = ClassB.x
class ClassB:
x = 2
y = ClassA.x
Can I somehow import ClassB before ClassA implementation? Or some sort of forward class declaration.