Last active
May 20, 2018 01:47
-
-
Save nooperpudd/07509ceff30089ee1aefc68b23a9e996 to your computer and use it in GitHub Desktop.
change stats
This file contains hidden or 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
#https://coderwall.com/p/jo39na/python-decorators-using-self | |
# todo it inlater | |
states = {"a":"b", "b":"c", "c":"d", "d","end"} | |
class Foo: | |
#skip some staff | |
def will_change_state(f): | |
def wrapper(*args): | |
ret = f(*args) | |
args[0].change_state() | |
return ret | |
return wrapper | |
def change_state(self): | |
self.state = states[self.state] | |
@will_change_state | |
def func1(self): | |
pass | |
@will_change_state | |
def func2(self): | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment