property()Easy Examples

Creates a managed attribute with getter, setter, and deleter

Basic property() usage

Simple demonstration of the property() built-in function.

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.

property() with different inputs

Calling property() with various argument types.

python
# More property() examples
print("property() is a Python built-in function")
print(f"Type: {type(property)}")

property() accepts different types of arguments and produces corresponding results.

Want to try these examples interactively?

Open Easy Playground