If you want to make a class attribute read-only, you'd typically use the _______ decorator.
- @readonly
- @property
- @readonly.setter
- @attribute.getter
To make a class attribute read-only, you typically use the @property decorator. This decorator allows you to define a method that can be used to access the attribute but not set it directly.
Loading...
Related Quiz
- You are required to implement a custom iterator that needs to maintain its internal state between successive calls. Which method should you implement in your class to achieve this?
- The _____ method in a metaclass is executed when a new class is created.
- You are developing a system where you have multiple classes, and you want to ensure that a particular set of methods is available in all these classes. How would you ensure this?
- To iterate over a list in reverse order using a for loop, one can use the _______ method of the list.
- In Python, _____ is a special method used to overload the ‘+’ operator for custom objects.