Attributes with superpowers
Project description
reacttrs
Reactive attributes extracted out from Textual.
from reacttrs import reactive
class Foo:
name = reactive("Paul")
age = reactive(33)
birth = reactive(1990)
def watch_name(self, old, new):
print(f"{old=}, {new=}")
def validate_name(self, name):
if name == "John":
print("Hey John!")
return name
def compute_age(self) -> int:
age = 2023 - self.birth
print(f"{age=}")
return age
foo = Foo()
foo.name = "John"
foo.name = "Steve"
foo.age
foo.birth = 1991
foo.age
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
reacttrs-0.1.4.tar.gz
(4.2 kB
view details)
Built Distribution
File details
Details for the file reacttrs-0.1.4.tar.gz
.
File metadata
- Download URL: reacttrs-0.1.4.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.24.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 811110153ec1523d878ad7344f362fc77f8fd3a971dbf31687159557de397385 |
|
MD5 | 0eb4f1d527e9463c334e98c400c9c4c2 |
|
BLAKE2b-256 | 52cd46d60ce2895910062d24740f3c9c26c2b049db731c40e9993265172dfeed |
File details
Details for the file reacttrs-0.1.4-py3-none-any.whl
.
File metadata
- Download URL: reacttrs-0.1.4-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.24.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | aaa6c517ed881df3182cf5bd016223337731551f31f8a3ba15355ca6137b1762 |
|
MD5 | 424f523fef33593fd6bbf4a98abc44a3 |
|
BLAKE2b-256 | 586441cc7ee494a2f776f9ee62eeecdceb56e779cfab192edac5cd966cd331d4 |