fncore
A collection of functional programming for Python.
Quickstart
$ pip install fncore
$ python3
>>> from fncore import *
>>> xs = [1,2,3]
>>> reduce(fn.operator.add, xs)
6
Background
fncore
was written to make the tools necessary for functional programming in Python easier to acces. By design, these tools are scattered across other modules: the built-ins functools
, itertools
and operator
and the community-managed toolz
and more-itertools
. fncore
collects the code from these sources and wraps them in a single namespace for easy access.
Use
Use of fncore
is as simple as pip
installing fncore
and then importing the package. It is recommended that you *
import fncore
, even though this goes against Python conventions.
from fncore import *
Importing fncore
in this way will bring some commonly used functions into your default namespace:
functools.reduce
functools.partial
toolz.functoolz.curry
toolz.dicttoolz.merge
toolz.dicttoolz.merge_with
And the functional-support code will be stored under the fn
namespace.
Location | Source |
---|---|
fn.functools |
functools |
fn.itertools |
itertools |
fn.operator |
operator |
fn.toolz |
toolz |
fn.more_itertools |
more-itertools |