Chapter 1: Introduction

Introduction

face Josiah Wang

While going through our course (especially in the lessons on advanced OOP), you may have stumbled upon labels like @property, @classmethod, @abstractmethod, and @dataclass. These are usually found perched comfortably before function or class definitions.

So what exactly are these labels? They have a name - these are called decorators.

In this lesson, we will focus only on really understanding what decorators are. This is really advanced knowledge, so don’t worry if you cannot wrap your head around it (yes, pun is completely intended)! This is something that is nice to know, but you will rarely need to use it to such detail in your general programming life. You can come back and re-read when you have the need for it!

This is the shortest lesson of all our guided learning materials, as we are focussing only on one specific feature. And there are no exercises (except the gymnastics that your brain needs to do) - just follow along the tutorial, guess the output of the example codes, and run the codes locally to verify.

Ready to start decorating?