Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/sup/pype

:snake: A sh-like forward pipe operator for Python
https://github.com/sup/pype

Last synced: 3 months ago
JSON representation

:snake: A sh-like forward pipe operator for Python

Awesome Lists containing this project

README

        

# Pype

A general purpose sh-like forward pipe operator for Python.

# Installation
`pip install python-pipe`

# Simple Example
```
from pype.pype import p

def hello_world(x):
print "Hi {0}!".format(x)

>>> 'Charles' |p| hello_world
Hi Charles!
```
# Slightly More Complex Example
```
from pype.pype import p

def double_and_sum(num_lst):
create_mapper = lambda (fn): lambda (lst): map(fn, lst)
mult = lambda n: n * 2

return num_lst |p| (mult |p| create_mapper) |p| sum

>>> [n for n in range(100)] |p| double_and_sum
9900
```