You are looking for @property
.
You may want to read up on how the @property
decorator works.
In short, and as you noted, you can use this to provide dynamically calculated attributes on an object. This is very useful in cases where you may have had code that accessed that as an attribute and you don't necessary want to change this to a function call.
However this by default is read-only. To permit the setting of value to that once more, you can create a setter decorator. Here is an example on how you might use it in the real world which also show you how you can make use of this.