def none_if_empty(fn):
 def wrapper(value):
  if ((value == '') or (value is None) or (value == [])):
   return None
  return fn(value)
 return wrapper

def none_if_empty ( fn ) : def wrapper ( value ) : if ( ( value == '' ) or ( value is None ) or ( value == [ ] ) ) : return None return fn ( value ) return wrapper
a decorator which returns none if its input is empty else fn(x) .