Skip to content

Show HN: Magrittr-like pipe syntax for IPython

github.com/smacke
2 pointssmacke1 comment
On HN

Hi HN, sharing my holiday season passion project, pipescript, which lets you write code like this in Jupyter Python notebooks:

42 |> $+1 # 43

The $ is a placeholder for the value in the previous pipeline step, like (.) in magrittr.

There's a ton more you can do thanks to macro expansion capabilities added by pipescript. Here's 5 factorial:

range(1, 6) |> reduce[$$] # 120

Placeholders can also be given informative names unlike in magrittr:

range(1, 6) |> reduce[$accum$current] # 120

The lack of names placeholders in magrittr had been my biggest complaint. Anyway I had a lot of fun scratching this itch and am really proud of the result, hope you like it too. :)

Comments

Some auto formatting italicized the text between * on different lines :')

Should be `reduce[$*$]`

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.