Skip to content

Instantly share code, notes, and snippets.

@techieji
Created January 12, 2022 03:28
Show Gist options
  • Save techieji/b37fedf3b11439baab947c3a0f210470 to your computer and use it in GitHub Desktop.
Save techieji/b37fedf3b11439baab947c3a0f210470 to your computer and use it in GitHub Desktop.
Oneline piping definition
pipe=type('',(),{'__ror__':lambda s,v:[setattr(s,'v',v),s][1],'__or__':lambda s,f:f(s.v)})()
# That's it. Really
if __name__ == '__main__':
# Example:
1 |pipe| (lambda x: x + 1) |pipe| print
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment