Skip to content

Instantly share code, notes, and snippets.

@sakakendo
Created March 2, 2019 15:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sakakendo/55fec44d0818aa8f10bb84c141d36f59 to your computer and use it in GitHub Desktop.
Save sakakendo/55fec44d0818aa8f10bb84c141d36f59 to your computer and use it in GitHub Desktop.
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