Syntax suger for python's functional programming as Unix pipes. - GitHub - GoodManWEN/pipeit: Syntax suger for python's functional programming as Unix pipes.
Project description
pipeit
This is a super simple wrapper , let's use python functional programming like Unix pipe!
Inspired by abersheeran/only-pipe , czheo/syntax_sugar_python , pipetools
Install
pip install pipeit
Usage
- Statements start with
PIPE
and end withEND
OR you can even ellipsis them. - There're only two objects(
PIPE
&END
) and three types(Filter
,Map
&Reduce
) in namespace, so feel free to usefrom pipeit import *
. - Convert filter into tuple or capital the first letter, e.g.
map(lambda x:x + 1) => (map , lambda x:x + 1)
orMap(lambda x:x + 1)
, however DO NOT MIX USE THEM. - It'll be 10% ~ 20% faster using the original python functional way than using these wrappers.
Example
>>> from pipit import PIPE , END , Map , Filter , Reduce
>>> data = PIPE | range(10) | (map , lambda x:x + 1) | (map , str) | list | END
>>> data
['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
# (map , lambda x:x + 1) equals to Map(lambda x:x + 1)
>>> func = lambda x: PIPE | range(x) | Map(lambda x:x + 1) | Map(str) | list | END
>>> func(10)
['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
Or you may want a more easy use.
>>> range(10) | Filter(lambda x:x<5) | list
[0, 1, 2, 3, 4]
>>> for _ in range(3) | Map(str):
print(repr(_))
'0'
'1'
'2'
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
pipeit-0.2.0.tar.gz
(9.5 kB
view hashes)
Built Distribution
pipeit-0.2.0-py3-none-any.whl
(10.0 kB
view hashes)