I have a code with several functions defined which I call from a main container code. Each new function uses variables obtained with the previous functions, so it looks kind of like this:
import some_package
import other_package
import first_function as ff
import secon_function as sf
import third_function as tf
import make_plot as mp
# Get values for three variables from first function
var_1, var_2, var_3 = ff()
# Pass some of those values to second function and get some more
var4, var5 = sf(var_1, var_3)
# Same with third function
var_6, var_7, var_8, var_9 = tf(var_2, var_4, var_5)
# Call plotting function with (almost) all variables
mp(var_1, var_2, var_3, var_5, var_6, var_7, var_8, var_9)
Is this more pythonic than using global variables? The issue with this methodology is that if I add/remove a new variable from a given function I'm forced to modify four places: the function itself, the call to that function in the main code, the call to the make_plot function in the main and the make_plotfunction itself. Is there a better or more recommended way to do this?