Skip to main content

classproperty

Decorator that converts a method with a single cls argument into a property that can be accessed directly from the class.

Attributes

AttributeTypeDescription
fgetcallableThe underlying callable method that is executed to return the property value when accessed from the class.

Constructor

Signature

def classproperty(
method: callable = None
) - > null

Parameters

NameTypeDescription
methodcallable = NoneThe method to be converted into a class property.

Methods


getter()

@classmethod
def getter(
method: callable
) - > [classproperty](classproperty.md?sid=django_utils_functional_classproperty)

Assigns a new method to serve as the property getter and returns the classproperty instance for decorator chaining.

Parameters

NameTypeDescription
methodcallableThe function to be used as the getter, which must accept a class as its first argument.

Returns

TypeDescription
[classproperty](classproperty.md?sid=django_utils_functional_classproperty)The current classproperty instance, allowing for fluent decorator usage.