I'm newbie with python programming and I'm facing an issue with Windows Memory, so I want to understand if the way I'm calling the other "subprogram" ic causing this problem. Basically I've done a main program from which I call the other .py (called second_py.py) like this:
from second_py import second_py
variable_1, variable_2 = second_py(input_1, input_2, input_3)
the second_py is ended with a return
and the input_1/2/3 can be different from where this second_py.py is executed in the main program.
is this way correct?
I've seen that it is also possible to use the subprocess.call
but honestly it is not clear to me how to pass to it the inputs.
CodePudding user response:
Here is a working example:
second_py.py
def my_function(a,b,c):
print ("I am a function from 'second_py' file!")
return(a b c, a*b*c)
first_py.py
from second_py import my_function
#Call the second_py function here
v1,v2=my_function(3,5,4)
print(v1,v2)
Output: