Skip to content

Instantly share code, notes, and snippets.

@porterjamesj
Last active December 23, 2015 05:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save porterjamesj/6589965 to your computer and use it in GitHub Desktop.
Save porterjamesj/6589965 to your computer and use it in GitHub Desktop.
fooling around with some FauxO tooling
from functools import wraps
from copy import deepcopy
def fauxothis(fn):
@wraps(fn)
def wrapper(self):
new = deepcopy(self)
fn(new)
return new
return wrapper
class Test(object):
@fauxothis
def stuff(self):
self.hey +=1
# test
a = Test()
a.hey = 1
a.stuff()
# a.hey => 1
b = a.stuff()
# a.hey => 1
# b.hey => 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment