I have a few pre-defined dictionaries in my python code, e.g.:
Parameter_A = {'Alpha':0.31, 'Beta':0.69}
Parameter_B = {'Alpha':0.55, 'Beta':0.75}
During execution of the python script (foo.py) I refer to the chosen parameter dictionary that I want to use (i.e. Parameter_A or Parameter_B). Like:
python foo.py A
And in the python script I have:
var = sys.argv[1]
Param = 'Parameter_' + var
The line (in script)
print 'Param = ', Param
gives output:
Param = Parameter_A
But, when I try to access the elements in the dictionary using this method,
Param['Alpha']
I get the error:
NameError: name 'Param' is not defined
I could see that in this method 'Param' (which has the string Parameter_A as its value) is of type 'str'.
But, I will really appreciate if someone can tell me how I can take 'A' or 'B' as a command line argument to indicate which one of the two dictionaries (Parameter_A or Parameter_B) my code should use.