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

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -