Additional functional tools for python not covered in the functools library
Project description
Functools Extra
Additional functional tools for python not covered in the functools library.
Installation
pip install functools-extra
How to use
Pipes
A pipe is a function that takes a value and list of functions and calls them in order.
So foo(bar(value))
is equivalent to pipe(value, bar, foo)
.
You can use built-in functions like list
, special operators from the operator module or custom functions.
from functools_extra import pipe
from operator import itemgetter
def add_one(x: int) -> int:
return x + 1
assert pipe(range(3), list, itemgetter(2), add_one) == 3
Development
The project is built with poetry. Check out the project and run
poetry install
to install the dependencies. After that you can run
poetry run pytest tests
to run the tests,
poetry run ruff format functools_extra tests --check
to check that the code is formatted correctly,
poetry run ruff format functools_extra tests
to format your code with ruff and
poetry run ruff check functools_extra tests
to lint the project.
License
This project is licensed under the terms of the MIT license.
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
Built Distribution
Hashes for functools_extra-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 33331584c8225478719d91d36275917b6da05c44c2109665fb2456b6c8cdb09b |
|
MD5 | b2a3fb6a6665a86235f40ef0998d99f8 |
|
BLAKE2b-256 | c86d7e7c1aca077e382b61e92d55e265df227354bb54ba7453a94b87a469397f |