I've got a dictionary of key, value pairs that are basically a shorthand name for a file and the location to which the file should be written (e.g. {"curv" : r"C:\\dir\moredir\curv.tif", "dem" : r"C:\\dir\moredir\dem.tif"}
. I would like to store the key as a variable name and its associated value as the variable value (dem = r"C:\\dir\moredir\dem.tif"
), but am not sure how (or if I should).
I'd like to do something along the lines of this but setting the local or global variables instead of attributes of a class.
The only way I know to assign the key, value pairs as variables is to manually write
key = dict["key"]
I could do this, or use dict["key"]
in the place of a variable, but this gets cumbersome across modules, where the dictionary names change. I would like to be able to run something to quickly convert that dictionary to variables so that curv
alone will suffice.
Backstory: The dictionary is the product of another module/function designed to create the file paths for output files. I do not have access to the path outside of the return from that function. I can always write a new function to return the values differently, however.