I am trying to learn how to dispatch an action that is related to an element of a dictionary.
I´ve seen a lot of times the formula dictionary[element].function()
, and there the function calls the element
of the dictionary.
I am trying to do that with this code, but I can not get the working method.
Any ideas?
(The last line of the code is the syntax that I want to use)
Thank you in advance!
def function(arg):
print 'Running ' + str(arg)
data={}
data[0]={'name':'Ruben', 'run':function}
data[1]={'name':'David', 'run':function}
print data
data[0].run()