I have the following json input parameters file
#input.json
{
"nx": 401,
"ny": 401,
"T" : 10,
"nt" : 20,
"D" : 0.2,
"Sgma": 0.243,
"M": 0.0052
}
that is passed onto different python
scripts, for eg.
#test1.py
import numpy,os
def simple(nx,ny,D,Sgma, M, T,nt): #parameters as function arguments
k = Sgma + 0.02
print("this is domain size", ny)
print("this is dif time", T)
print("this is K param", k)
#test2.py
import numpy,os
def simple_n(nx,ny,D,Sgma,M,T,nt): #parameters as function arguments
k = M + 0.02
print("this is domain size", ny)
print("this is sim time", D)
print("this is K param", k)
I execute both the above python
scripts through a main.py
that passes the input parameters with argparse.
As you can see, only some, not all of the parameters are required in individual scripts. My question: Is there a way to pass only the required arguments in simple()
?
For example: def simple(ny,T,k)
for test1.py
and def simple(ny,D,k)
for test2.py
rather than def simple(nx,ny,D,Sgma, M,T,nt)
. Since I will be dealing with large sets of parameters as initial config, I would like to know an efficient way to pass the initial parameters in different python
codes as function arguments. Thanks