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.0.tar.gz
(3.2 kB
view details)
Built Distribution
File details
Details for the file reacttrs-0.1.0.tar.gz
.
File metadata
- Download URL: reacttrs-0.1.0.tar.gz
- Upload date:
- Size: 3.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.23.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5dc46f2917bdb2e70d41666a3b745da5390279a2309c3afefbe22eb74e8fefd1 |
|
MD5 | c3cc4ec2cdc71ae17dc9347d00c4fe3f |
|
BLAKE2b-256 | 7ad27c8cbe8f17c4a692d6fbfd91e90b2e7aa5842034b7a3cb7519be8f7e6ae9 |
File details
Details for the file reacttrs-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: reacttrs-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.23.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1ac994beba181150cb2c1f92e9e3f32146f972caf8bdad91d3aaf6eba7757228 |
|
MD5 | 68e72432eaedcf2d415d0202d5a748b4 |
|
BLAKE2b-256 | 5967e37c67afe1bb42dce2901e52dae55a45abaad7ca59e09cf4aba0d376bf31 |