Skip to content

Instantly share code, notes, and snippets.

@hjwp
Created October 23, 2014 09:26
Show Gist options
  • Save hjwp/2cc523b66d9c0fe41c4b to your computer and use it in GitHub Desktop.
Save hjwp/2cc523b66d9c0fe41c4b to your computer and use it in GitHub Desktop.
Simple decorator challeng
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