The best solution to avoid circular imports. If A imports B, then B should not import A, or import from A (although python is very permissive and will tolerate almost everything). Here, main imports submodule and both use printa(). You can write printa() and num_values in a third module, and import thirdmod in both main and submodule.
Gribouillis
Posting Maven
3,101 posts since Jul 2008
Reputation Points: 1,130
Solved Threads: 761
Skill Endorsements: 11
There is no problem in jumping back and forth if you do it through class instances, for example in module A
# mod A
from B import foo
class Bar(object):
def baz(self):
print("qux")
x = Bar()
foo(x) # call function foo from module B
and in module B
# mod B
def foo(bar):
bar.baz() # call method .baz() defined in module A
Notice that module B uses module A features without importing anything from A.
Gribouillis
Posting Maven
3,101 posts since Jul 2008
Reputation Points: 1,130
Solved Threads: 761
Skill Endorsements: 11
Question Answered as of 3 Months Ago by
Gribouillis