import six


def str_to_intfloat(s):
    """Convert str to int or float.

    Args:
        s (:obj:`str`):
            String to convert to float if it has a period or int if not.

    Returns:
        :obj:`int` or :obj:`float`

    """
    if isinstance(s, six.string_types):
        if "." in s and s.replace(".", "").isdigit():
            return float(s)
        if s.isdigit():
            return int(s)
    return s