Reputation: 10939
I have two Python classes in two separate modules. The modules reference each other, so I must use the import XXX
syntax rather than from XXX import YYY
. I can't figure out how to access a class defiend in one module in the other, importing module though:
### testa.py
import testb
class TestA():
...
### testb.py
import testa
class TestB(testa.TestA): # doesn't work
...
How do I do this?
Upvotes: 0
Views: 55
Reputation: 20508
You can solve this by putting import testb
after the definition of TestA
. However, you might need to rethink your module structure since circular imports are difficult to deal with.
Upvotes: 1