Created
March 2, 2019 15:28
-
-
Save sakakendo/55fec44d0818aa8f10bb84c141d36f59 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from icecream import ic | |
import json | |
def hello(): | |
print("hello world") | |
def night(): | |
print("good night") | |
def birthday(name): | |
print("happy birthday "+name) | |
funcs={} | |
def add_func(func): | |
funcs[func.__name__]=func | |
def test(): | |
print(funcs) | |
add_func(hello) | |
print(funcs) | |
add_func(birthday) | |
funcs["hello"]() | |
funcs["birthday"](name="sakakendo") | |
order="birthday"+"/"+json.dumps({"name":"sakakendo"}) | |
print("dumped order",order) | |
func,arg_str=order.split("/") | |
print(func,arg_str) | |
arg=json.loads(arg_str) | |
funcs[func](**arg) | |
test() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment