Skip to main content
Help us improve PyPI by participating in user testing. All experience levels needed!

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

This version
History Node


History Node


History Node


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
smartcompose-0.1.2-py3-none-any.whl (4.6 kB) Copy SHA256 hash SHA256 Wheel 3.4 Jul 8, 2014 (6.5 kB) Copy SHA256 hash SHA256 Source None Jun 13, 2014

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page