I want to access the python variable from config file dynamically like below.
config file:
total_var_count = 4
var1=1
var2=2
var3=3
var4=4
main_file.py
import config as cf
for variable_no in range(1,int(cf.total_var_count)+1):
print(cf.var+str(variable_no))
another method I have tried:
new_var ='var'+str(1)
print(cf.new_var) # which is also not working.
I have tried the above methods to access but its not working. Could someone tell me how I can access the variable from config file dynamically?