以下のコードで辞書からget_productname関数を呼び出すにはどうすればよいですか?クラスのDictキーとしての機能
test = {
'get_productname' : {
'id' : 1,
'active' : 1,
}
}
class search(object):
def __init__(self):
for key, value in test.items():
if test[key]['active']:
... here i want to call the "get_productname" function from the dict key name
self.key()
... HOW CAN I DO THIS?
def get_productname(self, id):
...
return productname
質問がありますか? –