znfields 0.1.2
pip install znfields
Latest version
Released:
Lazy evaluation of dataclass fields
Navigation
Unverified details
These details have not been verified by PyPIMeta
- License: Apache Software License (Apache-2.0)
- Author: Fabian Zills
- Requires: Python <4.0, >=3.10
Classifiers
- License
- Programming Language
Project description
znfields
Provide a getter
and setter
for dataclasses.fields
to allow e.g. for lazy
evaluation or field content validation.
pip install znfields
Example
The znfields.field
supports all arguments from dataclasses.field
with the
additional getter
argument.
import dataclasses
import znfields
def getter(self, name) -> str:
return f"{name}:{self.__dict__[name]}"
def setter(self, name, value) -> None:
if not isinstance(value, float):
raise ValueError(f"Value {value} is not a float")
self.__dict__[name] = value
@dataclasses.dataclass
class MyModel(znfields.Base):
parameter: float = znfields.field(getter=getter, setter=setter)
Project details
Unverified details
These details have not been verified by PyPIMeta
- License: Apache Software License (Apache-2.0)
- Author: Fabian Zills
- Requires: Python <4.0, >=3.10
Classifiers
- License
- Programming Language
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file znfields-0.1.2.tar.gz
.
File metadata
- Download URL: znfields-0.1.2.tar.gz
- Upload date:
- Size: 7.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.12.7 Linux/6.5.0-1025-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5d9e1894f1a766dd5675db1b1b05cfc6b5c9d78da84a5b01d0baffd5ca49a065 |
|
MD5 | a83a444ccd933cc462316df2ea5c10bf |
|
BLAKE2b-256 | 2c3d4332bc037cf7bf3b5fd2a8e48f5c79d14c8d33b69af3d100a5a0e1e6ca3a |
File details
Details for the file znfields-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: znfields-0.1.2-py3-none-any.whl
- Upload date:
- Size: 7.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.12.7 Linux/6.5.0-1025-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 621c4746276a55637bb251494251e09671f4f4e74fbdaad7158d8a225e0d94e8 |
|
MD5 | f98ad77d4b609db8a64a18c6c604e508 |
|
BLAKE2b-256 | b37efaa726144e92f8473157b402d5adec74daf9279605774d6e5b7cf881e676 |