GvR seems to somewhat hate the FP list idioms, but at least functions are first class objects and he didn't totally wipe out the few basic FP functions in Python 3.
The standard library includes category of functional programming modules:
itertools
: Functions creating iterators for efficient looping.functools
: Higher-order functions and operations on callable objects.operator
: Function versions of operators for higher-order use.
-
partial(func, *args, **keywords)
: Returns a partial object (attributes:func
,args
,keywords
) called as a function:drop1A = partial(re.sub, 'A', '', count=1) drop1A('AbAb') == 'bAb'
-
partialmethod
: Used for method definitions in objects:class Foo(): def id(x): return x three = partialmethod(id, 3)
-
reduce(function, iterable[, initializer])
Composable, pure and lazy tools for list processing as done in functional languages.
See: toolz-pypy, toolz-docs, tools-github