top | item 46512772

Show HN: Magrittr-like pipe syntax for IPython

2 points| smacke | 1 month ago |github.com

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. :)

1 comment

order

smacke|1 month ago

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

Should be `reduce[$*$]`