dprop-0.42
توضیحات
Everything is connected, maan!
| ویژگی | مقدار |
|---|---|
| سیستم عامل | - |
| نام فایل | dprop-0.42 |
| نام | dprop |
| نسخه کتابخانه | 0.42 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Kosio Karchev |
| ایمیل نویسنده | kosiokarchev@gmail.com |
| آدرس صفحه اصلی | - |
| آدرس اینترنتی | https://pypi.org/project/dprop/ |
| مجوز | MIT |
## dprop
#### *Everything is connected, maan!*
----------
This tiny package implements the notion of "dependent properties", whose values
are computed based on other properties and cached for re-use, but then smartly
invalidated when a `(great-)*(grand)?parent` property's value changes.
Here is a simple example:
```python
from dprop import independent, depends_on
class Class:
a = independent(float) # type info optional
@depends_on(a)
def b(self):
print('computing b')
return 6 * self.a
def __init__(self, a: float):
# independent properties can be set inside and outside the class as usual
self.a = a
inst = Class(7)
assert inst.a == 7
assert inst.b == 42 # prints "computing b"
assert inst.b == 42 # value is re-used! (nothing printed)
# Re-setting an independent property invalidates (does not actually delete,
# though) all "later" properties.
inst.a = 26/6
assert inst.b == 26 # prints "computing b"
```
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.8 | Python |
نحوه نصب
نصب پکیج whl dprop-0.42:
pip install dprop-0.42.whl
نصب پکیج tar.gz dprop-0.42:
pip install dprop-0.42.tar.gz