Skip to content

Instantly share code, notes, and snippets.

@aj07mm
Last active September 29, 2018 20:44
Show Gist options
  • Save aj07mm/c353b3da218171572d371483bb0e2f17 to your computer and use it in GitHub Desktop.
Save aj07mm/c353b3da218171572d371483bb0e2f17 to your computer and use it in GitHub Desktop.
decorators.py
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