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.1.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.1-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: curry_fp-1.3.1.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.1.tar.gz
Algorithm Hash digest
SHA256 e45ecc0cb51ce3e50cdad2c88ed6a9ca812ed1c1528650219e8c10f5e8c029f8
MD5 b2d3fe500f842759fb74d81453b76e46
BLAKE2b-256 d99bfbfe8588eeba90e7f32f2a7c88639c84b30b8be4ac0f4a06ae21ea3efe62

See more details on using hashes here.

File details

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

File metadata

  • Download URL: curry_fp-1.3.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a9f5f4d83ac807d2e7431d7833f47aee51b12891f3afb3f3dde03aa532ce979a
MD5 207e1de87d23a36fb628b8a037392e39
BLAKE2b-256 5175d1fa4753b690997fdcf96346c094e408240dc2ad7d7dc9450ccb144bcbdf

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