Skip to content

Instantly share code, notes, and snippets.

@h0rn3t
Created July 12, 2015 08:24
Show Gist options
  • Save h0rn3t/c0e7bda9e390f44a2e4c to your computer and use it in GitHub Desktop.
Save h0rn3t/c0e7bda9e390f44a2e4c to your computer and use it in GitHub Desktop.
fluent decorator
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