Skip to content
Pyrula
Pre-release: the packages are not on PyPI yet, so pip install does not resolve. Build from source to try it today.

Composition

from pyrula import pipe, flow, partial
# pipe threads a value through functions
pipe(" Hello World ", str.strip, str.lower, lambda s: s.replace(" ", "-")) # "hello-world"
# flow builds a reusable function from the same steps
slugify = flow(str.strip, str.lower, lambda s: s.replace(" ", "-"))
slugify(" Hello World ") # "hello-world"
# partial fixes leading arguments; the result works in pipe and flow
def clamp(lo, hi, x):
return max(lo, min(hi, x))
partial(clamp, 0, 255)(300) # 255

View this page as Markdown