python - imported function calling function from original file -
this question has answer here:
i have python program a imports program b.
program a has function foo , main classes , global variables etc.
program b has function bar.
program a's main function ran user input during runtime bar, a calls bar: b.bar(stuff).
b.bar() tries call a.foo(). proper way of doing this?
the proper way avoid doing as possible, e.g. have third script c containing foo avoid circular.
one workaround otherwise write b so:
def bar(): import foo foo() and not import a @ top level. way import happens when bar called a loaded , won't import error.
Comments
Post a Comment