Module scrapfly.polyfill.cached_property

Classes

class cached_property (factory)
Expand source code
def __get__(self, instance, owner):
    # Build the attribute.
    attr = self._factory(instance)

    # Cache the value; hide ourselves.
    setattr(instance, self._attr_name, attr)

    return attr

Descriptor (non-data) for building an attribute on-demand on first use.

is called such: factory(instance) to build the attribute.