Encapsulation and decorators made easy.
Project description
The encapsulation library
Introducing: the From class.
Decorators made easy, piece-wise oprations on product types, controlling evaluation order.
For maintainable data pipelines.
It's a monad (sorry 🍪).
Installation
pip install -e encapsulation
Getting started
Get started by
from encapsulation.base import From
obj = From(
lambda x: "hi " + x
)("there")
print(obj)
Easy decorator superpowers:
from encapsulation.base import From
def inspect(x: str):
"""some function you want to call each time"""
print(x)
# you can also turn inspect into a proper decorator using
agent = From().apply(inspect)
@agent
def task(val: str):
"""Some task"""
print("[this is a task]")
task("hiho")
The above will both evaluate task("hiho") and leave its return type untouched, while also
executing agent(task) each time the task function gets called.
Congratulations! You can now stop writing convoluted wrappers each time you want to implement a decorator, and use From instead 😎
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file encapsulation-0.1.2.tar.gz.
File metadata
- Download URL: encapsulation-0.1.2.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b47b1ccd226a35c97ee7d88ab20bfb43daa4a4795e27b3a14c21b6f528aadc88
|
|
| MD5 |
5cf13cdb37d37d97f6af7e7538698373
|
|
| BLAKE2b-256 |
d3a9fef89b17d989564cc9728056f4d9b4b36a6d830bea1d36044e3e05ac8926
|
File details
Details for the file encapsulation-0.1.2-py3-none-any.whl.
File metadata
- Download URL: encapsulation-0.1.2-py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5e7fe677efb5a619ea92fe45a68513657542fed6d527af19792225ae4c1c4a92
|
|
| MD5 |
63549e7f3d0c901af1e224f33c2f2335
|
|
| BLAKE2b-256 |
9e7606735e71a8508b197120558857933ee1a10dbc71a4fa56eef88f71a7853c
|