pyfuncol
A Python functional collections library. It extends collections built-in types with useful methods to write functional Python code. It uses Forbidden Fruit under the hood.
Installation
pip install pyfuncol
Usage
To use the methods, you just need to import pyfuncol. Some examples:
import pyfuncol
[1, 2, 3, 4].map(lambda x: x * 2).filter(lambda x: x > 4)
# [6, 8]
{1, 2, 3, 4}.map(lambda x: x * 2).filter(lambda x: x > 4)
# {6, 8}
["abc", "def", "e"].group_by(lambda s: len(s))
# {3: ["abc", "def"], 1: ["e"]}
{"a": 1, "b": 2, "c": 3}.flat_map(lambda kv: {kv[0]: kv[1] ** 2})
# {"a": 1, "b": 4, "c": 9}
API
For lists, please refer to the docs.
For dictionaries, please refer to the docs.
For sets, please refer to the docs.
For more details, please have a look at the API reference.
Documentation
See https://pyfuncol.readthedocs.io/.
Compatibility
Since it depends on Forbidden Fruit, it only works on CPython.
Contributing
See the contributing guide for detailed instructions on how to get started with the project.
License
pyfuncol is licensed under the MIT license.