https://github.com/v-spassky/drainage
🚿 Implementation of pipe expressions for Python.
https://github.com/v-spassky/drainage
functional-programming pipe python
Last synced: 4 months ago
JSON representation
🚿 Implementation of pipe expressions for Python.
- Host: GitHub
- URL: https://github.com/v-spassky/drainage
- Owner: v-spassky
- Created: 2023-04-09T16:51:20.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-05-15T07:31:01.000Z (over 2 years ago)
- Last Synced: 2025-06-28T12:13:15.583Z (5 months ago)
- Topics: functional-programming, pipe, python
- Language: Python
- Homepage:
- Size: 30.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# `drainage`
A Python library that provides an implementation of UNIX-like pipes for Python
functions. Chain your functions together using the pipe (`|`) operator and
make your code more functional and expressive.
### Installation
```
pip install git+https://github.com/v-spassky/drainage.git
```
### Usage
```python
from drainage import piped, filtered, collect
@piped
def add_one(x):
return x + 1
@filtered
def is_even(x):
return x % 2 == 0
result = [1, 2, 3, 4] | add_one | is_even | collect()
print(result) # Output: [2, 4]
```
### Development
In the project directory, run:
```
poetry install
```
```
poetry shell
```
There are `poe` scripts for all kinds of checks:
- to run tests:
```
poe test
```
- to run linter:
```
poe lint
```
- to run type checker:
```
poe typecheck
```
- to run all checks:
```
poe check-all
```
- to build docs locally:
```
poe doc
```