Skip to content

Instantly share code, notes, and snippets.

@Singletoned
Created March 23, 2022 16:36
Show Gist options
  • Save Singletoned/3456f4dc837e3003b26c20bdbf481130 to your computer and use it in GitHub Desktop.
Save Singletoned/3456f4dc837e3003b26c20bdbf481130 to your computer and use it in GitHub Desktop.
function_map = {}
def register_doer(name):
"This is a decorator factory. It should create and return a decorator"
def inner(func):
function_map[name] = func
return func
return inner
@register_doer("Do Flibble!")
def do_flibble():
return "This is the flibble result"
@register_doer("Do Blurble!")
def do_blurble():
return "This is the blurble result"
@register_doer("Do Blamble!")
def do_blamble():
return "This is the blamble result"
assert function_map["Do Flibble!"]() == "This is the flibble result"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment