Last active
August 29, 2015 14:15
-
-
Save daboross/ba5d32b5443f1ae938e1 to your computer and use it in GitHub Desktop.
Test
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
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"))) |
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
$ 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