Skip to main content

Functional currying in Python. 🥘

Project description

🥘 Curry fp

Functional currying for Python.

Simple ⬦ Clear ⬦ Concise

GitHub Actions Workflow Status PyPI - Version PyPI - Python Version


Background

Currying is a technique targeting strategic code composition, breaking apart a function into a series of functions, allowing arguments to be applied piece-by-piece until all parameters are fulfilled.

Usage

Curry fp is a powerful tool that can be used as a decorator on Callable objects for the purpose of currying.

Features

  • Allows for 1 or more arguments to be passed to the curried function at a time, including all at once.
  • Default values can be specified using ... (Ellipsis) as an argument, at any point.
  • Keyword arguments can be used, allowing for arguments to be passed in whenever available.

Example

from curry_fp import curry

@curry
def sum_all(a: int, b: int=2, c: int=3) -> int:
    return a + b + c

Without using default values

>>> sum_all(1)(2)(3)
6

Using default values

>>> sum_all(1)(...)
6

All arguments at once

>>> sum_all(1, 2, 3)
6

All arguments at once (with defaults)

>>> sum_all(1, 2, ...)
6

Using keyword arguments in any order

>>> sum_all(b=2)(c=3)(a=1)
6

See test/test_curry.py for more examples. ✨

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

curry_fp-1.3.3.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

curry_fp-1.3.3-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

Details for the file curry_fp-1.3.3.tar.gz.

File metadata

  • Download URL: curry_fp-1.3.3.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.13.2 Linux/5.15.167.4-microsoft-standard-WSL2

File hashes

Hashes for curry_fp-1.3.3.tar.gz
Algorithm Hash digest
SHA256 d4dba72461543bd77da9bc6b5bbe5ea21ded3fc72cc28fa0c26b77dfdd1ec430
MD5 eff7674463e8d3ea675c0e347c94acbe
BLAKE2b-256 6599a781d7c570e18cd8f3f01754e59de62ed231cdc60f7ffaa18f7e6fc3e55f

See more details on using hashes here.

File details

Details for the file curry_fp-1.3.3-py3-none-any.whl.

File metadata

  • Download URL: curry_fp-1.3.3-py3-none-any.whl
  • Upload date:
  • Size: 3.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.13.2 Linux/5.15.167.4-microsoft-standard-WSL2

File hashes

Hashes for curry_fp-1.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c217191895b3fc7d6c0c80e9d06c48739f5f629a91437ddfe00cf7b2a782128c
MD5 421ecd4b44a442a6df4d9fed6ad1fed5
BLAKE2b-256 5297475544afb4ad39bcc888ae12dc8664fef5680acab46113370246b18ee89e

See more details on using hashes here.

Supported by

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