Skip to main content

pythoniac port forwardable from Ruby

Project description

# Forwardable

pythoniac port forwardable from Ruby


## Installation

```bash
$ pip install https://github.com/hachibeeDI/forwardable/archive/master.zip
```


## Example

### delegator

```python
>>> from forwardable import Forwardable, def_delegator
>>> class Hoge(object):
... __metaclass__ = Forwardable
... startswith = def_delegator('aa')
... endswith = def_delegator('aa')
... balse = def_delegator('aa', 'replace') # with proxy
...
... def __init__(self):
... self.aa = 'test hoge'

>>> h = Hoge()
>>> h.startswith('test')
True
>>> h.endswith('test')
False
>>> h.balse('test', 'is it greeeeet')
'is it greeeeet hoge'

```

### multi delegators

```python

>>> from forwardable import Forwardable, def_delegators
>>> class Foo(object):
... __metaclass__ = Forwardable
... _ = def_delegators('aa', ('startswith', 'endswith', 'replace', ))
...
... def __init__(self):
... self.aa = 'test hoge'

>>> f = Foo()
>>> f.startswith('test')
True
>>> f.endswith('test')
False
>>> f.replace('test', 'is it greeeeet')
'is it greeeeet hoge'

```

## Testing

```bash
python tests.py
```

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

forwardable.py-0.0.11.tar.gz (2.9 kB view details)

Uploaded Source

File details

Details for the file forwardable.py-0.0.11.tar.gz.

File metadata

File hashes

Hashes for forwardable.py-0.0.11.tar.gz
Algorithm Hash digest
SHA256 6759ec30430c476fae27b1a4f8a1f6761b416c118187e8d3fe6adc62e6ee827f
MD5 afa44250d7729904c1210a203b872a66
BLAKE2b-256 1bc86daccc28c6fc99696d4decf174689e64e0ce55cddaab34d8c9f07991fd21

See more details on using hashes here.

Supported by

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