Practice mode Python

What is the effect of decorating a method with @property?

Correct answer B. The method can be accessed like an attribute, without parentheses

Explanation

property turns a method into a managed attribute, so obj.area calls the getter automatically. Setter and deleter methods can be added with @area.setter and @area.deleter, which allows validation while keeping simple attribute syntax. Caching is what functools.cached_property provides, and privacy is only a naming convention in Python.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.