Decorators – Another Way to Create Properties

Learn about the concept of decorators in Python.

We can create properties using decorators. This makes the definitions easier to read. Decorators are a ubiquitous feature of Python syntax, with a variety of purposes. For the most part, decorators modify the function definition that they precede.

Convert the getter method to the property attribute

The property() function can be used with the decorator syntax to turn a get method into a property attribute, as follows:

Get hands-on with 1200+ tech skills courses.