Skip to main content

Functional Pipelines implemented in python

Project description

Functional Pipeline

PyPI version pipeline status coverage report PyPI Documentation Status

Functional languages like Haskell, Elixir, and Elm have pipe functions that allow the results of one function to be passed to the next function.

Using functions from functools, we can build composition in python, however it is not nearly as elegant as a well thought out pipeline.

This library is designed to make the creation of a functional pipeline easier in python.

>>> from operator import add, mul

>>> from functional_pipeline import pipeline, tap

>>> result = pipeline(
...     10,
...     [
...         (add, 1),
...         (mul, 2)
...     ]
... )

>>> result

This pattern can be extended for easily dealing with lists or generators.

>>> from functional_pipeline import pipeline, String, join

>>> names = [
...     "John",
...     "James",
...     "Bill",
...     "Tiffany",
...     "Jamie",
... ]

>>> result = pipeline(
...     names,
...     [
...         (filter, String.startswith('J')),
...         (map, lambda x: x + " Smith"),
...         join(", "),
...     ]
... )

>>> result
'John Smith, James Smith, Jamie Smith'

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
functional_pipeline-0.3.0-py3-none-any.whl (7.0 kB) Copy SHA256 hash SHA256 Wheel py3

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page