Skip to main content

Syntax suger for python's functional programming as Unix pipes. - GoodManWEN/pipeit

Project description

pipeit

fury licence pyversions Publish Build

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 with END.
  • There're only two objects(PIPE & END) and three types(Filter ,Map & Reduce) in namespace, so feel free to use from pipeit import *.
  • Convert filter into tuple , e.g. map(lambda x:x + 1) => (map , lambda x:x + 1)

Example

Some description.

>>> 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 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


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.1.4.tar.gz (3.7 kB view hashes)

Uploaded Source

Built Distribution

pipeit-0.1.4-py3-none-any.whl (5.1 kB view hashes)

Uploaded Python 3

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