Skip to content

Instantly share code, notes, and snippets.

@daboross
Last active August 29, 2015 14:15
Show Gist options
  • Save daboross/ba5d32b5443f1ae938e1 to your computer and use it in GitHub Desktop.
Save daboross/ba5d32b5443f1ae938e1 to your computer and use it in GitHub Desktop.
Test
class TestDecorator():
def __init__(self, function):
print("before: {}".format(hasattr(function, "test_value")))
function.test_value = self
print("after: {}".format(hasattr(function, "test_value")))
@TestDecorator
def test_function():
return "hi"
print("later: {}".format(hasattr(test_function, "test_value")))
$ python3 test.py
before: False
after: True
later: False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment