code: def _to_number(cls, string):
          
          try:
              if float(string) - int(string) == 0:
                  return int(string)
              return float(string)
          except ValueError:
              try:
                  return float(string)
              except ValueError:
                  return string
docs: Convert string to int or float.