Python with pipes, utils, and pipe utils
Project description
Pipe Utils
Python with pipes, utils, and pipe utils.
Install
pip install pipe-utils
Docs
Example
from pipe_utils import *
words = "I just think pipes are neat!"
result = (
Pipe(words)
| obj.lower()
| obj.replace("!", "")
| obj.split()
| group_by(len)
| sorted_dict()
| unwrap
)
print(result)
# {1: ['i'], 3: ['are'], 4: ['just', 'neat'], 5: ['think', 'pipes']}
And, if you're feeling dangerous, override builtin functions
like filter, map, and all by importing from pipe_utils.override:
from pipe_utils.override import *
data = [[1, -3, 4], [1, 2, 3], [2, 3, 4], [5, -1, 4]]
result = (
Pipe(data)
| filter(all(it >= 0))
| map(sum_by(it * it))
| unwrap(as_list)
)
print(result) # [14, 29]
And, if you're feeling extra dangerous, you can use arrow syntax to clean up some of those brackets:
from pipe_utils.override import *
data = [[1, -3, 4], [1, 2, 3], [2, 3, 4], [5, -1, 4]]
result = (
Pipe >> data
| filter >> all(it >= 0)
| map >> sum_by(it * it)
| unwrap >> as_list
)
print(result) # [14, 29]
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pipe_utils-0.5.0.tar.gz.
File metadata
- Download URL: pipe_utils-0.5.0.tar.gz
- Upload date:
- Size: 25.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9366a1d6691201b5312a74f279bf7f673e8fc5a2f1b12875f96d753b02c0a28a
|
|
| MD5 |
b2f755bdb84f81754444f9ae1e8e9666
|
|
| BLAKE2b-256 |
51f8ee8a3421b37c0c4cd252fc76c35989337ac115d6bc0f9c61e0aafd9f0e7a
|
File details
Details for the file pipe_utils-0.5.0-py3-none-any.whl.
File metadata
- Download URL: pipe_utils-0.5.0-py3-none-any.whl
- Upload date:
- Size: 18.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d9486ea918aefb5689e3e9efaef26d321f02fa2028c4a6305c6f220965650194
|
|
| MD5 |
e559b761ab430b81ba7f785b42a3bd70
|
|
| BLAKE2b-256 |
1eb40469c30badb0b7d62811a764216fbef6b43f64b6834d1ad978b35231cad5
|