I have this function in python:
def executecommand(call):
if call.data == "/getpair":
return getpaircmd(call.message)
elif call.data == "/menu":
return menucmd(call.message)
elif call.data == "/setalarm":
return setalarmcmd(call.message)
And I was hoping to replace it with object and .get(call.data)
message, like this:
def executecommand(call): return { "/getpair": getpaircmd(call.message), "/menu": menucmd(call.message), "/setalarm": setalarmcmd(call.message) }.get(call.data)
But it seems like it calls every function on the list.
So, is there a way to simplify it?