Created
July 12, 2015 08:24
-
-
Save h0rn3t/c0e7bda9e390f44a2e4c to your computer and use it in GitHub Desktop.
fluent decorator
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
from functools import wraps | |
from copy import deepcopy | |
def fluent(method): | |
"""Used to define fluent API class methods""" | |
@wraps(method) | |
def wrapped(self, *args, **kwargs): | |
dupe = deepcopy(self) | |
method(dupe, *args, **kwargs) | |
return dupe | |
return wrapped |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment