def try_int(candidate, default_value=0):
 try:
  return int(candidate)
 except (ValueError, TypeError):
  return default_value

def try_int ( candidate , default_value = 0 ) : try : return int ( candidate ) except ( ValueError , TypeError ) : return default_value
try to convert candidate to int .