Created
October 23, 2014 09:26
-
-
Save hjwp/2cc523b66d9c0fe41c4b to your computer and use it in GitHub Desktop.
Simple decorator challeng
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
def absolute(fn): | |
# this decorator currently does nothing | |
def modified_fn(x): | |
return fn(x) | |
return modified_fn | |
def foo(x): | |
return 1 - x | |
assert foo(3) == -2 | |
@absolute | |
def foo(x): | |
return 1 - x | |
assert foo(3) == 2 # this will fail, get is passing! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment