-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathhtml_decorators.py
More file actions
45 lines (31 loc) · 924 Bytes
/
html_decorators.py
File metadata and controls
45 lines (31 loc) · 924 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
def div(func):
# You have to code here!
def wrapper(*args, **kwargs):
result = func(*args, **kwargs)
return f'<div>{result}</div>'
return wrapper
def article(func):
# You have to code here!
def wrapper(*args, **kwargs):
return f'<article>{func(*args, **kwargs)}</article>'
return wrapper
def p(func):
# You have to code here!
def wrapper(*args, **kwargs):
return f'<p>{func(*args, **kwargs)}</p>'
return wrapper
# Here you must apply the decorators, uncomment this later
# @div
# @article
# @p
@p
def saludo(nombre):
return f'¡Hola {nombre}, ¿Cómo estás?'
def run():
print(saludo('Jorge'))
if __name__ == '__main__':
run()
# We want to have three different outputs 👇🏼
# <div>¡Hola Jorge, ¿Cómo estás?'</div>
# <article>¡Hola Jorge, ¿Cómo estás?'</article>
# <p>¡Hola Jorge, ¿Cómo estás?'</p>