property()

Built-in FunctionPython 2.0+Intermediate

Creates a managed attribute with getter, setter, and deleter

Quick Info

Documentation
Official Docs
Python Version
2.0+

Learn by Difficulty

Quick Example

python
class Circle:
    def __init__(self, radius):
        self._radius = radius

    @property
    def area(self):
        return 3.14159 * self._radius ** 2

c = Circle(5)
print(c.area)

property() is a built-in function that creates a managed attribute with getter, setter, and deleter.

Try in Playground

Tags

builtinfunctioncoreoopdescriptordecorator

Related Items