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

Uploaded Python 3

File details

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

File metadata

  • Download URL: curry_fp-1.3.2.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.2.tar.gz
Algorithm Hash digest
SHA256 a431ffea6ce22cb063ffd197aea8983d1a6cac200aae3444b2d02cb641def5f4
MD5 cdcc5ba123c15bf555494d2c4ab26535
BLAKE2b-256 bfc2ae600206e1a334981ea4e993d98f8f30a6c379f117bdb1e287e69c399854

See more details on using hashes here.

File details

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

File metadata

  • Download URL: curry_fp-1.3.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 15a95d6cb9a85660c65962668f4ab03b787a01343150c0a59bf9eb78317069dd
MD5 53c922c3f966d01b49779fc7dd7430e1
BLAKE2b-256 29e604a460f0b8f367c1287b8f4257246d5fb82b44a4cb89afc844a30d63aad3

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