Property Methods
property.getter()
Replace the accessor used when a managed attribute is read. The new getter normally accepts the instance and returns the attribute value. The other accessor functions are retained. The method returns a new property descriptor; the original is unchanged. Rebind it to the class attribute (or use the decorator form with the same attribute name). In local CPython 3.13.5, passing None retains the existing accessor; construct a new property explicitly with a missing accessor to omit it. Missing accessors cause AttributeError when the corresponding operation is attempted.
Formal Syntax & Structure
python syntaxpython
descriptor.getter(fget, /)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| fget | Callable | None | Replacement accessor; None retains the existing accessor in CPython 3.13.5. |
Return Value
property
New descriptor with the selected accessor replaced.
Working Example
Example Snippetpython
def read(self): return self._valuedef write(self, value): self._value = valuedef erase(self): del self._valueoriginal = property(None, write, erase)updated = original.getter(read)class Item: value = updateditem = Item()item._value = 4print(item.value)print(original.fget is None, updated is original)