I am trying to take a basic dictionary temp = {'key':array([1,2])} loaded from a .mat file with scipy.io.loadmat. Turn the keys in the Python dictionary file returned by loadmat() into variable names with values the same as the representing keys.
So for example:
temp = {'key':array([1,2])}
turned into
key = array([1,2])
I know how to grab the keys with temp.keys(). Then grabbing the items is easy but how do I force the list of strings in temp.keys() to be variable names instead of strings.
I hope this makes sense but this is probably really easy I just can't think how to do it.
Cheers
In python, method parameters can be passed as dictionnaries with the **
magic:
def my_func(key=None):
print key
#do the real stuff
temp = {'key':array([1,2])}
my_func(**temp)
>>> array([1,2])