def try_or_none(f):
 def f_or_none(x):
  try:
   return f(x)
  except:
   return None
 return f_or_none

def try_or_none ( f ) : def f_or_none ( x ) : try : return f ( x ) except : return None return f_or_none
wraps f to return none if f raises an exception assumes f takes only one input .