x = 5 b = 6 from second import c def print_(): result = c print (ersult) print_()
from First import x,b class addition(): def process(self): c = x + b return c
the variables in the first file (first)
the second file obtain the variables then do the function
then the first file obtain the result from second file and do the
I wonder is it possible!!!
or the right choice is the variable be separated in third file, or if the code isn’t long, combine all in the same file
This won’t work correctly because you have a circular import.
First.py imports from
second.py and visa versa. Rather than trying to import
First.py into second, have
addition.process take the necessary parameters to do your computation, import
First.py, and call
class addition(): def process(self, x, b): c = x + b return c
x = 5 b = 6 from second import addition def print_(): result = addition().process(x, b) print (result) print_()
Besides Christian Dean’s answer you could have a look here: run a python script from another python script passing in args.