Function Details: property

Description


Property attribute.


Extended Description


The property() function returns a property object. Properties are a way to manage attribute access in classes. They allow you to define methods that will be called when an attribute is accessed, set, or deleted. This provides a way to customize attribute behavior without changing the class interface. Properties can be used for data validation, computed attributes, or to make attributes read-only.


Read More about property from Python Documentation

Function Signature


property(fget: Optional[Callable] = None, fset: Optional[Callable] = None, fdel: Optional[Callable] = None, doc: Optional[str] = None) -> property

Module: builtins

Class: property

Parameters



Parameter List


  • fget: Optional[Callable]
  • fset: Optional[Callable]
  • fdel: Optional[Callable]
  • doc: Optional[str]

Return


Returns a property object that can be used as a decorator or assigned directly to a class attribute.


Return Type


property

Output

Explanation

This example demonstrates how to use properties for getter, setter, and computed attributes.