What does the @property decorator do in a Python class?
- It defines a class method
- It defines a getter method
- It defines a setter method
- It defines a static method
The @property decorator defines a getter method for a class attribute, allowing you to access it as if it were an instance variable.
Loading...
Related Quiz
- How would you use a metaclass to automatically register all subclasses of a base class in Python?
- What is the base class in Python from which all exceptions inherit?
- Which of the following sorting algorithms is most efficient for small-sized data sets?
- In Python, ____ is used to define a function that takes an arbitrary number of positional arguments.
- What is the primary use of the __init__ method in a Python class?