def _int_or_float(s):
 if isinstance(s, float):
  return s
 try:
  return int(s)
 except (ValueError, TypeError):
  try:
   return float(s)
  except (ValueError, TypeError) as e:
   raise ValueError(str(e))

def _int_or_float ( s ) : if isinstance ( s , float ) : return s try : return int ( s ) except ( ValueError , TypeError ) : try : return float ( s ) except ( ValueError , TypeError ) as e : raise ValueError ( str ( e ) )
converts an a string to an int if possible .