From the course: Python: Design Patterns

Unlock this course with a free trial

Join today to access over 24,700 courses taught by industry experts.

Solution: Decorator

Solution: Decorator

- [Instructor] How did it go? Was it easier than you thought? That's the power of using design patterns. As indicated, let's create a decorator class that adds the HTML bold text. Copy the make_blink decorator code first. Ctrl + C. And then paste it here, Ctrl + V. Change the name to make_bold. And change the text to instead of blink, b. And then close tag, b. Which makes text bold in HTML. Now it's time to apply the decorators. Let's add the blink text by typing @make_blink. And next our bold text. Type @make_bold. That's it. It's time to test the code by clicking Test My Code. It shows the correct results.

Contents