I would like to be able to do the following, in Python 2.7:
for function in ['function1', 'function2', 'function3', 'function4']:
some_dictionary [function] = function (an_argument)
However, when I try to do so, an error rises. The following code does the thing I would like the upper code to do:
some_dictionary ['function1'] = function1 (an_argument)
some_dictionary ['function2'] = function2 (an_argument)
some_dictionary ['function3'] = function3 (an_argument)
some_dictionary ['function4'] = function4 (an_argument)
Is there a more compact way of writing the latter code, something similar to the former one?
Thanks in advance,
Logicum