I have two Python codes. Code Python_A
consists of a function and returns values val1
, val2
, val3
. Code Python_B
consists of a function whose argument values have to be arg1 = val1
, arg2 = val2
, arg3 = val3
. How do I implement this?
The sequence of steps in which I would want this to happen is:
Python_A
is executed Python_B
that has to have its arguments as val1
, val2
, val3
.Several posts have shown ways of importing stationary values from one python code into another. But, none could be found which show importing mutable values.
How to get this right?
The value of a variable won't generally be saved once a script has completed running. To save a variable, one can write it out to a file, either directly, if it's some thing simple like a string or float, or using a serialized like pickle (https://docs.python.org/3/library/pickle.html) or JSON if it's a more complex data structure. Then reload the values when you want to use them in a new script.