Skip to main content

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

encapsulation-0.1.2.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

encapsulation-0.1.2-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

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

Hashes for encapsulation-0.1.2.tar.gz
Algorithm Hash digest
SHA256 b47b1ccd226a35c97ee7d88ab20bfb43daa4a4795e27b3a14c21b6f528aadc88
MD5 5cf13cdb37d37d97f6af7e7538698373
BLAKE2b-256 d3a9fef89b17d989564cc9728056f4d9b4b36a6d830bea1d36044e3e05ac8926

See more details on using hashes here.

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

Hashes for encapsulation-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5e7fe677efb5a619ea92fe45a68513657542fed6d527af19792225ae4c1c4a92
MD5 63549e7f3d0c901af1e224f33c2f2335
BLAKE2b-256 9e7606735e71a8508b197120558857933ee1a10dbc71a4fa56eef88f71a7853c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page