Skip to main content

Pipe your python functions!

Project description

small_pipe

small_pipe (small_pp for short) is a minimal abstraction layer for piping operations in python.

Examples

You can alias your functions and then use it in the pipe function like so

import small_pipe as pp

exists = pp.where(lambda x: x is not None)

pp.pipe(
    [1, 2, 3, None, 4],
    exists
)
[1, 2, 3, 4] # returns

For more complex cases consider importing functions directly as in

from small_pipe import pipe, each, where, reduce

pipe.debug = True
double = lambda x: x * 2

pipe(
    range(15),
    each(double),
    where(lambda x: x % 2 == 0),
    list,
    reduce(lambda x, y: x + y, 20),
    double
)
<map object at 0x000002055852B1F0>
<filter object at 0x000002055852B040>
[0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28]
230
460  # returns

Docs

pipe is literally just a function that loops over *args and calls them on the positional argument

each, where and reduce wrap higher order functions map, filter and functools.reduce respectively so that they can be used without the iterable argument

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

small_pipe-0.1.0.tar.gz (2.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

small_pipe-0.1.0-py3-none-any.whl (3.0 kB view details)

Uploaded Python 3

File details

Details for the file small_pipe-0.1.0.tar.gz.

File metadata

  • Download URL: small_pipe-0.1.0.tar.gz
  • Upload date:
  • Size: 2.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for small_pipe-0.1.0.tar.gz
Algorithm Hash digest
SHA256 108030a2b0e7338ab0ee9af90492f7b80a8034becc7a7a23f894b954284bb5af
MD5 6c898958f30aa7d93f1eb2244d5d90c5
BLAKE2b-256 bcc7b765d64f10b92a987464628ed74cd0c481865279bacb14295db621769b14

See more details on using hashes here.

File details

Details for the file small_pipe-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: small_pipe-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for small_pipe-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d078221bb7217119a96056eb2212815fbb3bd80624fd3ce3cfd7c02fd0e74b6f
MD5 6a0f0997bfbc03c38961abb09e3334b9
BLAKE2b-256 8f2bdec0f250ac411423ec28629a42307189afcada95279828f7a6e8ceee531c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page