Skip to content

Commit 5357e89

Browse files
committed
Refactor decorator
1 parent b3286a3 commit 5357e89

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

decorator.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,17 @@
55

66

77
def makebold(fn):
8-
@wraps(fn)
9-
def wrapped():
10-
return "<b>" + fn() + "</b>"
11-
return wrapped
8+
return getwrapped(fn, "b")
129

1310

1411
def makeitalic(fn):
12+
return getwrapped(fn, "i")
13+
14+
15+
def getwrapped(fn, tag):
1516
@wraps(fn)
1617
def wrapped():
17-
return "<i>" + fn() + "</i>"
18+
return "<%s>%s</%s>" % (tag, fn(), tag)
1819
return wrapped
1920

2021

0 commit comments

Comments
 (0)