From aada3e54a689b5e6abc36c4d4ce7834459e1dff8 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sun, 19 Jul 2020 20:49:10 -0500 Subject: [PATCH] solved challenged Finally after thinking a lot, i did the first decorator with a long way to understand better how decorators work, after that, i shorten the method. --- html_decorators.py | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/html_decorators.py b/html_decorators.py index 8d9c421..ae12490 100644 --- a/html_decorators.py +++ b/html_decorators.py @@ -1,22 +1,25 @@ def div(func): - # You have to code here! - pass - + def wrapper(*args, **kwargs): + result = func(*args, **kwargs) + modify = "
" + result + "
" + return modify + return wrapper def article(func): - # You have to code here! - pass - - + def wrapper(*args, **kwargs): + result = func(*args, **kwargs) + return f'
{ result }
' + return wrapper + def p(func): - # You have to code here! - pass - + def wrapper(*args, **kwargs): + return f'

{ func(*args, **kwargs) }

' + return wrapper # Here you must apply the decorators, uncomment this later -# @div -# @article -# @p +#@div +@article +#@p def saludo(nombre): return f'¡Hola {nombre}, ¿Cómo estás?'