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.3.tar.gz
(3.4 kB
view details)
Built Distribution
File details
Details for the file reacttrs-0.1.3.tar.gz
.
File metadata
- Download URL: reacttrs-0.1.3.tar.gz
- Upload date:
- Size: 3.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.23.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 22cafec1eab5726f33d9eadd216097c842b9664a26a3677bda030d6c0d2bc848 |
|
MD5 | 20e781370004facc0404962116fccdcb |
|
BLAKE2b-256 | fcc74610de85b3bb7335a1ef60a399ddb5d8fc85ab3d737dc42e0c4f49e26d9c |
File details
Details for the file reacttrs-0.1.3-py3-none-any.whl
.
File metadata
- Download URL: reacttrs-0.1.3-py3-none-any.whl
- Upload date:
- Size: 4.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.23.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2475b202fcb6adfc5b6925a78082f74af2833710e3666d844a4e3e5e0c706964 |
|
MD5 | 04875524bdb0bc0813aa1926754b8960 |
|
BLAKE2b-256 | 97874ef9f0fbda09d1fb2b13a54427a500a80d4b8a10e6ed2866af8ef6f4f37d |