Created
December 4, 2023 22:54
-
-
Save brettcannon/49ec8201cb95ff37b6dae9197ece86ea to your computer and use it in GitHub Desktop.
Provide a function that lets you use a fluent-style API when a method returns e.g. `None` instead of `self`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fluent(bound_method, /, *args, **kwargs): | |
"""Call a bound method and return `self` from that method.""" | |
bound_method(*args, **kwargs) | |
return bound_method.__self__ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment