I'd like to call a function like this:
c = selion([{'title': "mytitle1",
'my_field': 'value_1',
'other': 'other_value'},
{'title': "mytitle2",
'my_field': 'value_2',
'other': 'other_value'},])
The problem is that I would like 'my_field'
to be sometimes a function to call back.
- How to test, in the
selion()
function, if it's a string or a function and call it back? - if I want to pass in a function that is inside a class (something like
self.calculate('client_x')
), does it work out of the box like a normal function?
All in all I'd like this code to work:
class Test():
def calculate_value(self):
return 'test'
c = self.selion([{'title': "mytitle1",
'my_field': self.calculate_value,
'other': 'other_value'},
{'title': "mytitle2",
'my_field': 'value_2',
'other': 'other_value'},])