Skip to content

Instantly share code, notes, and snippets.

@salexkidd
Created February 16, 2015 14:43
Show Gist options
  • Save salexkidd/893cf6575e6282a6d0ef to your computer and use it in GitHub Desktop.
Save salexkidd/893cf6575e6282a6d0ef to your computer and use it in GitHub Desktop.
Python decorator leraning 2
def remove_five(dl):
dl.remove(5)
return dl
def test_decorator(func):
print("now test_decorator")
def _wrapper(dl):
dl = remove_five(dl)
return func(dl)
return _wrapper
@test_decorator
def test_func_1(data_list):
return data_list
def test_func_2(data_list):
return data_list
if __name__ == "__main__":
print(
remove_five(
test_func_2(range(1, 11))
)
)
print(test_func_1(range(1, 11)))
"./base.py" 28L, 480C written
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment