Created
July 4, 2017 10:56
-
-
Save allieus/fea2adf1ab0a72c628d6af0a8759ae6a to your computer and use it in GitHub Desktop.
Filter Decorator Example
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 myfilter(filter_fn, alter_value): | |
def wrap(fn): | |
def inner(*args): | |
values = (i if filter_fn(i) else alter_value for i in args) | |
return fn(*values) | |
return inner | |
return wrap |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment