Skip to main content

Pipe.py

A non-intrusive Python pipeline.

There are only pipeline. If you want more functional tools, you should look for another library.

Install

pip install only-pipe

Or fetch from github

pip install git+https://github.com/abersheeran/only-pipe

Usage

Use pipeline to pass data as a positional parameter to the next function:

from pipe import F

range(10) | F(filter, lambda x: x % 2) | F(sum) == 25

Or you need to pass multiple parameters through the pipeline:

from pipe import FF


def get_data():
    return 1, 2


get_data() | FF(lambda x, y: x + y) == 3

Use alias like follow code, you can use map/filter/reduce more conveniently:

from functools import reduce
from pipe import F

Filter = F(F, filter)
Map = F(F, map)
Reduce = F(F, reduce)

range(100) | Filter(lambda x: x % 2) | Map(lambda x: x * x) | Reduce(lambda x, y: x + y)

Set Global

Maybe you don't want to use from pipe import F in every file of the entire project, you can use the following code to set it as a global function, just like min/max/sum.

import pipe

pipe.set_global(pipe.F, pipe.FF)

Maybe you also want to expose functools.reduce to the world, just like map/filter.

import pipe
import functools

pipe.set_global(pipe.F, pipe.FF, functools.reduce)

More

No more ~ This library has less than ten lines of valid code, but it is very effective.

If you like it, please give a Star. 😀

This repository is released under the MIT. Do what you want!

Metadata

Release files for only-pipe 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for only-pipe 2.0.0
File Size Uploaded
only-pipe-2.0.0.tar.gz 2.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for only-pipe 2.0.0
File Interpreter ABI Platform
only_pipe-2.0.0-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 5.3 kB

Release files / only-pipe-2.0.0.tar.gz

Download URL only-pipe-2.0.0.tar.gz
Size 2.2 kB
Tags Source
SHA-256 checksum
How to use checksums
c39b1faa1acb2be4d6390c853af307343531ecff52d260bd116ddc54f73ee31b
BLAKE2b-256 checksum
How to use checksums
0b77d53c65f500b2fc36a282b93115a264c92e0b9615521281cf374e7aca8c76
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.9

Release files / only_pipe-2.0.0-py2.py3-none-any.whl

Download URL only_pipe-2.0.0-py2.py3-none-any.whl
Size 3.1 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
e9ad4dbcbafefe06ae03b7f0e8eba1b4dd718910a3266d51fbe7088a04fd1ed3
BLAKE2b-256 checksum
How to use checksums
ac8024ea3fd2f0258e5e70a54edd3f6be39de75b9286f6cef2bdab912a24ce7c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.9

Release history Release notifications | RSS feed

This release

2.0.0 This release

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page