sidekick.properties
Functions in this module are helpers intended to create convenient and declarative idioms when declaring classes. Perhaps it is not entirely correct calling them “functional”, but since some patterns such as lazy properties are common in functional libraries, Sidekick has a module for doing that.
This library can be installed independently from the rest of sidekick distribution using pip install sidekick-properties. Prefer depending on sidekick-properties if your project only use those functions.
Quick start
from typing import NamedTuple
from sidekick.properties import lazy, alias, delegate_to # or from sidekick.api import *
class Person(NamedTuple):
name: str
age: int
full_name = alias('name')
p = Person('Karl Heinrich', age=29)
Now p.full_name is now an alias to p.name. This usage simply exposes an attribute under a different name. func:alias can be configured in many different ways by choosing mutability and simple transformations between the exposed alias and the original attribute.
class Employee(NamedTuple):
person: Person
role: str
name = delegate_to('person')
age = delegate_to('person')
@lazy
def photo(self):
return download_from_server(f'http://url.img/employees/{self.name}')
Metadata
Release files for sidekick-properties 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| sidekick-properties-0.1.0.tar.gz | 8.1 kB | Details |
Release files / sidekick-properties-0.1.0.tar.gz
| Download URL | sidekick-properties-0.1.0.tar.gz |
|---|---|
| Size | 8.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
059a9b2c0679155f44adf2499bc1e444542bab7bedd86dbdcf03c2da57bf43e2
|
|
BLAKE2b-256 checksum How to use checksums |
ff7487e2d9431b8d96234d3a3ce373ef75f31929310fbdfaf898e37a14f84851
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.0 importlib_metadata/3.7.2 packaging/20.9 pkginfo/1.7.0 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2
|