Skip to content

Commit d29fa82

Browse files
authored
Update decorator.py
I would extend the decorator from the base class. The reason is that we still expect an italic bold text to be a text! So we expect the behaviours of the basic TextTag class to exists in the class that is being decorated. Example: If you add the following method to the TextTag class, you expect your decorated objects still be able to call that method: ``` def say_hello(): print 'hello I am text!' ```
1 parent bcfc2e3 commit d29fa82

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

structural/decorator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def render(self):
1313
return self._text
1414

1515

16-
class BoldWrapper(object):
16+
class BoldWrapper(TextTag):
1717
"""Wraps a tag in <b>"""
1818
def __init__(self, wrapped):
1919
self._wrapped = wrapped
@@ -22,7 +22,7 @@ def render(self):
2222
return "<b>{}</b>".format(self._wrapped.render())
2323

2424

25-
class ItalicWrapper(object):
25+
class ItalicWrapper(TextTag):
2626
"""Wraps a tag in <i>"""
2727
def __init__(self, wrapped):
2828
self._wrapped = wrapped

0 commit comments

Comments
 (0)