I have a set of table names
1. EOM 2.STMT 3.LOOKUP etc
I want to associate these table names with some variables names such as
1. start_time, 2. end_time, 3. total_time etc.
The way I want to write these variable names is something like
1. start_time_EOM, end_time_EOM, total_time_EOM 2. start_time_STMT, end_time_STMT,total_time_STMT 3. start_time_LOOKUP,end_time_LOOKUP,total_time_LOOKUP
Can this be done in python, and how? (Note: I am new to Python, and still trying to learn).
Yup, dictionaries are solution:
tables=["A","B","C"]
vars = ["var1","var2","var3"]
dict={}
for val in tables:
for val2 in vars:
dict[val2+"_"+val] = foo
dict[val2+"_"+val] = bar
dict[val2+"_"+val] = foobar
#and so
Hope if helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With