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()
).get()
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))
| as_list
).get()
print(result) # [14, 29]
And, if you're feeling extra dangerous, you can use arrow syntax to clean up
some of those brackets (and the P
pipe alias):
from pipe_utils.override import *
data = [[1, -3, 4], [1, 2, 3], [2, 3, 4], [5, -1, 4]]
result = (
P >> data
| filter >> all(it >= 0)
| map >> sum_by(it * it)
| as_list
).get()
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
pipe-utils-0.4.0.tar.gz
(25.0 kB
view hashes)
Built Distribution
pipe_utils-0.4.0-py3-none-any.whl
(17.3 kB
view hashes)
Close
Hashes for pipe_utils-0.4.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2607509aeb6ce5b87b4c7060216f15392ff1e398f4520abd6af626629cf2693e |
|
MD5 | 1efa9e61556f441ba9eb1aca5fb4c8b3 |
|
BLAKE2b-256 | d796bd5ebf029956e2727379e643107f145a828cea8392047570db91e535b10b |