https://github.com/v2e4lisp/pipeto
pipe for python
https://github.com/v2e4lisp/pipeto
Last synced: 8 months ago
JSON representation
pipe for python
- Host: GitHub
- URL: https://github.com/v2e4lisp/pipeto
- Owner: v2e4lisp
- Created: 2013-10-24T14:03:44.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2013-10-29T13:18:35.000Z (over 12 years ago)
- Last Synced: 2024-08-09T21:10:05.110Z (almost 2 years ago)
- Language: Python
- Size: 211 KB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# linux pipe style port to python
code like this: `pipe(1) | float | str | list | done` !
[](https://travis-ci.org/v2e4lisp/pipeto)
tested on 2.7, 3.2, 3.3
## Install
```bash
pip install pipeto
```
## API
* `pipe(arg)`
generate a pipable object pipe to next function.
@param : arg {mixed}
* `done(arg)`
get the actural value out of pipable object
* `compose(fn)`
Compose functions. Can be used as a decorator.
@alias : composable
@param : fn {callable}
## example
```python
from pipeto import *
import operator as op
inc = lambda x: x + 1
double = lambda x: x + x
# pipe
pipe(1) | float | str | list | done # == ['1', '.', '0']
pipe(2) | inc | done # == 3
pipe(2) | inc | double | done # == 6
pipe([1,2,3]) | sum | done # == 6
# compose
newfn = compose(inc) | double
newfn(2) # == double(inc(2))
```