Easy delegation with composition
Project description
Decorate a class with @delegate(attribute_name, method_names) to delegate the methods in method_names to the attribute attribute_name:
In [1]: from smartcompose import delegate
In [2]: @delegate('_n', ('__add__', '__mul__'))
...: class NumberWrapper:
...: def __init__(self, n):
...: self._n = n
...:
In [3]: n = NumberWrapper(10)
In [4]: n + 2
Out[4]: 12
In [5]: n * 3
Out[5]: 30
For now, only compatible with Python 3.
pip install smartcompose
Project details
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
smartcompose-0.1.2.zip
(6.5 kB
view details)
Built Distribution
File details
Details for the file smartcompose-0.1.2.zip
.
File metadata
- Download URL: smartcompose-0.1.2.zip
- Upload date:
- Size: 6.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 07f8100587dd9a3992c3d570ef637544aa7361e0d9ed35ccaa5b6ac80652d9c4 |
|
MD5 | bec33b989c2d5bb0b280c26d2055ee87 |
|
BLAKE2b-256 | 392288d2bec7586da4c492c44a1625959d725a64af56bdc12e377b9f603409e5 |
File details
Details for the file smartcompose-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: smartcompose-0.1.2-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 410af7f77b3b71e0edfd47f391f7487817ca08d7b5e7c05d44d613ff881b0b22 |
|
MD5 | 20dc5d087c71e864d5b90a2804299a0b |
|
BLAKE2b-256 | 1bb93c9e2e502706f28ae5209114c878210ec1561594c3b1a09ca11524bc8272 |