Advertisement
Guest User

Untitled

a guest
Feb 24th, 2020
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.54 KB | None | 0 0
  1. def Boolefy(func):
  2.     """
  3.    This class is meant to be used only as a decorator
  4.    ex:
  5.        @Boolefy
  6.        some_func_operating_bools(a, b, c, d="something"):
  7.            ...
  8.  
  9.    :param func: the function to be decorated with parameters boolified
  10.  
  11.    :return: func will be called with all parameters coverted to its bool equivalent
  12.    the return will be the naturally expected by func
  13.    """
  14.  
  15.  
  16.     def wrapped(*args, **kwargs):
  17.         cast_args = map(bool, args)
  18.         return func(*cast_args, **kwargs)
  19.  
  20.     return wrapped
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement