Skip to main content

Functional collections extension functions for Python

Project description

pyfuncol

CI GitHub license

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

pyfuncol-0.1.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

pyfuncol-0.1-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

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

Hashes for pyfuncol-0.1.tar.gz
Algorithm Hash digest
SHA256 6d2a716bf96102fe0ce3740ec457dd5b514362ccf852c0d00dc96ecda76e1f77
MD5 0f0f984db274307e621a5a3d255d6099
BLAKE2b-256 8e8c7c49d1d4dbb8c7670607d15fb17249e57493a1a53dce095134d3c3abb845

See more details on using hashes here.

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

Hashes for pyfuncol-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 394ad1c168aefcde1c971b0bd23a48117f3c641e96c6131074225df77c068d34
MD5 53e9e5c19ab9409a01b2e86df673c941
BLAKE2b-256 8bf4fcd1585ec52136ebb44a79f7729f934ce1e7e0cdd44b751d8225446e8244

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page