Decorators¶
flutils offers the following decorators:
flutils.
cached_property
(func)[source]¶A property decorator that is only computed once per instance and then replaces itself with an ordinary attribute.
Deleting the attribute resets the property.
Example
Code:
from flutils import cached_property class MyClass: def __init__(self): self.x = 5 @cached_property def y(self): return self.x + 1Usage:
>>> obj = MyClass() >>> obj.y 6 >>> obj.y 6New in version 0.2.0
This decorator is a derivative work of cached_property and is:
Copyright © 2015 Daniel Greenfeld; All Rights Reserved
Also this decorator is a derivative work of cached_property and is: