docs: def toNumber (str, default=None):
      """toNumber(str[, default]) -> integer | float | default
  
      Converts the given string to a numeric value.  The string may be a
      hexadecimal, integer, or floating number.  If string could not be
      converted, default (None) is returned.
  
      Examples:
  
      >>> n = toNumber("0x2A")
      >>> assert type(n) is int and n == 42
  
      >>> n = toNumber("42")
      >>> assert type(n) is int and n == 42
  
      >>> n = toNumber("42.0")
      >>> assert type(n) is float and n == 42.0
  
      >>> n = toNumber("Foo", 42)
      >>> assert type(n) is int and n == 42
  
      >>> n = toNumber("Foo")
      >>> assert n is None
      """
      value = default
  
      try:
          if str.startswith("0x"):
              value = int(str, 16)
          else:
              try:
                  value = int(str)
              except ValueError:
                  value = float(str)
      except ValueError:
          pass
  
      return value