Skip to main content

class_property

This class acts as a property decorator for class-level attributes, allowing methods to be accessed as properties on a class or its instances. It wraps getter and setter functions as class methods to manage attribute access and modification at the class level. The class also ensures that metadata such as docstrings and names are correctly preserved from the underlying getter function.

Constructor

Signature

def class_property(
getter: callable = None,
setter: callable = None
) - > null

Parameters

NameTypeDescription
gettercallable = NoneThe function to be used as a getter, which will be converted to a classmethod.
settercallable = NoneThe function to be used as a setter, which will be converted to a classmethod.

Methods


setter()

@classmethod
def setter(
setter: callable
) - > [class_property](property.md?sid=celery_local_class_property)

Creates a new class_property instance that associates a specific setter method with the existing getter.

Parameters

NameTypeDescription
settercallableThe function to be used as the setter for this class property.

Returns

TypeDescription
[class_property](property.md?sid=celery_local_class_property)A new instance of class_property containing both the original getter and the newly defined setter.