You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP
Socket
Sign inDemoInstall
Socket

curry-fp

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

curry-fp

Functional currying in Python. 🥘

1.3.1
PyPI
Maintainers
1

🥘 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. ✨

Keywords

python

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts