def exception_when_false_wrapper(func, exception_class, value_error_message_template):
 def g(target, *args, **kwargs):
  val = func(target, *args, **kwargs)
  if val:
   return val
  else:
   raise exception_class((value_error_message_template % target))
 g.__name__ = func.__name__
 g.__doc__ = func.__doc__
 return g

def exception_when_false_wrapper ( func , exception_class , value_error_message_template ) : def g ( target , * args , ** kwargs ) : val = func ( target , * args , ** kwargs ) if val : return val else : raise exception_class ( ( value_error_message_template % target ) ) g . __name__ = func . __name__ g . __doc__ = func . __doc__ return g
wrap a function to raise an exception when the return value is not true .