I wanted to access a dictionary created in file1.py from file2.py based on value passed in a variable. Both files in same directory.
File1.py looks like
dict_test_1 = {'a':1, 'b': 2}
dict_test_2 = {'a':11, 'b': 12}
file2.py looks like:
import file1
def fun(dict_name):
var_a = file1.dict_name['a'] ## I wanted an equivalent of file1.dict_test_1['a'] or file.dict_test_2['a']
fun(deciding variable which is coming from run time) # Calling function
I need to access either of dictionary created in file1.py at run time by 'dict_name' but the problem is python actually sees 'dict_name' as it one of the dictionary defined in file1.py instead of taking value of 'dict_value' variable passed in function 'fun' and looking for corresponding dictionary.
Any solutions??