Last active
September 29, 2018 20:44
-
-
Save aj07mm/c353b3da218171572d371483bb0e2f17 to your computer and use it in GitHub Desktop.
decorators.py
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
def decorator(fn): | |
def inner(name): | |
return '<a>' + fn(name) + '</a>' | |
return inner | |
def decorator_parameterized(html_tag): | |
def decorator(fn): | |
def inner(name): | |
return '<{}>'.format(html_tag) + fn(name) + '</{}>'.format(html_tag) | |
return inner | |
return decorator | |
@decorator_parameterized(html_tag='b') | |
def foo(name): | |
return '<span>' + name + '</span>' | |
if __name__ == '__main__': | |
print(foo('julio')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment