Created
March 23, 2022 16:36
-
-
Save Singletoned/3456f4dc837e3003b26c20bdbf481130 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
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