Functional collections extension functions for Python
Project description
pyfuncol
A Python functional collections library. It extends collections built-in types through Forbidden Fruit with useful methods to write functional Python code.
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]
["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: map
, filter
, flat_map
, flatten
, contains
, distinct
, foreach
, group_by
, is_empty
, size
, find
, index_of
.
For dictionaries: map
, filter
, flat_map
, contains
, foreach
, is_empty
, size
, to_list
.
Compatibility
Since it depends on Forbidden Fruit, it only works on CPython.
License
pyfuncol is licensed under 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
File details
Details for the file pyfuncol-0.1.tar.gz
.
File metadata
- Download URL: pyfuncol-0.1.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6d2a716bf96102fe0ce3740ec457dd5b514362ccf852c0d00dc96ecda76e1f77 |
|
MD5 | 0f0f984db274307e621a5a3d255d6099 |
|
BLAKE2b-256 | 8e8c7c49d1d4dbb8c7670607d15fb17249e57493a1a53dce095134d3c3abb845 |
File details
Details for the file pyfuncol-0.1-py3-none-any.whl
.
File metadata
- Download URL: pyfuncol-0.1-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 394ad1c168aefcde1c971b0bd23a48117f3c641e96c6131074225df77c068d34 |
|
MD5 | 53e9e5c19ab9409a01b2e86df673c941 |
|
BLAKE2b-256 | 8bf4fcd1585ec52136ebb44a79f7729f934ce1e7e0cdd44b751d8225446e8244 |