From 9cf1d38742d0fecbf6723698e5f8e288f2a98310 Mon Sep 17 00:00:00 2001 From: Gabriel Date: Sat, 8 Aug 2020 10:45:58 -0500 Subject: [PATCH] Included html decorators --- html_decorators.py | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/html_decorators.py b/html_decorators.py index 8d9c421..dae3f7a 100644 --- a/html_decorators.py +++ b/html_decorators.py @@ -1,30 +1,46 @@ def div(func): - # You have to code here! - pass + def wrapper(*args, **kwargs): + print('
', end='') + print(func(*args, **kwargs), end='') + print('
') + return wrapper def article(func): - # You have to code here! - pass + def wrapper(*args, **kwargs): + print('
', end='') + print(func(*args, **kwargs), end='') + print('
') + return wrapper def p(func): - # You have to code here! - pass + def wrapper(*args, **kwargs): + print('

', end='') + print(func(*args, **kwargs), end='') + print('

') + return wrapper # Here you must apply the decorators, uncomment this later -# @div -# @article -# @p -def saludo(nombre): +@div +def saludo1(nombre): return f'¡Hola {nombre}, ¿Cómo estás?' +@article +def saludo2(nombre): + return f'¡Hola {nombre}, ¿Cómo estás?' -def run(): - print(saludo('Jorge')) +@p +def saludo3(nombre): + return f'¡Hola {nombre}, ¿Cómo estás?' +def run(): + saludo1('Jorge') + saludo2('Jorge') + saludo3('Jorge') + if __name__ == '__main__': run()