def str_to_num(text):
 try:
  return int(text)
 except ValueError:
  try:
   return float(text)
  except ValueError:
   return text

def str_to_num ( text ) : try : return int ( text ) except ValueError : try : return float ( text ) except ValueError : return text
convert a string to a number .