Skip to content
Andy Brice edited this page Mar 22, 2018 · 4 revisions

Pypework is a functional pipeline library for Python.

It allows you to rewrite messy nested function calls such as this:

title_sanitized =
  replace(replace(replace(lowercase("Lorem Ipsum Dolor 2018/02/18"), " ", "_"), "/", "-"), "@", "at")

title_sanitized # -> "lorem_ipsum_dolor_2018-02-18"

In a far more readable format like this:

title_sanitized = (
  "Lorem Ipsum Dolor 2018/02/18"
    >> f.lowercase
    >> f.replace("/", "-")
    >> f.replace(" ", "_")
    >> f.replace("@", "at")
)

title_sanitized # -> "lorem_ipsum_dolor_2018-02-18"
Clone this wiki locally