Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def Boolefy(func):
- """
- This class is meant to be used only as a decorator
- ex:
- @Boolefy
- some_func_operating_bools(a, b, c, d="something"):
- ...
- :param func: the function to be decorated with parameters boolified
- :return: func will be called with all parameters coverted to its bool equivalent
- the return will be the naturally expected by func
- """
- def wrapped(*args, **kwargs):
- cast_args = map(bool, args)
- return func(*cast_args, **kwargs)
- return wrapped
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement