Skip to content

Instantly share code, notes, and snippets.

@4e1e0603
Last active August 6, 2021 08:19
Show Gist options
  • Save 4e1e0603/dd25a5427de454e2b55e459985832ef7 to your computer and use it in GitHub Desktop.
Save 4e1e0603/dd25a5427de454e2b55e459985832ef7 to your computer and use it in GitHub Desktop.
Comment for Functional Python Article
# Functional composition with `>>` operator.
class Value:
def __init__(self, value) -> None:
self.value = value
def __rshift__(self, that):
print(f"{that.__name__}({self.value})")
return Value(that(self.value))
def __call__(self):
return self.value
Value(x) >> f >> g >> h >> print
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment