My python program reads a pre-defined dictionary to get certain values for processing. I need to be able to change the values of the dictionary. But, as program will be converted to executable file, it should not be defined inside the program.
I was thinking like defining it in a text file. I don't want to write extra code to parse and populate dictionary. I need to know if there is any way to define a dict in a text file and assigning its content directly to python dict.
Like this:
In the text file:
{'a':1,'b':2,'c':3}
NB: The actual one is bit more enrich with values. This is just an example.
In the program:
dict_variable = f.read()
So if you print the variable it will be a dictionary object:
{'a':1,'b':2,'c':3}
and can be accessed like dict_variable['a']
.
Is there any way to do this?