def str2boolintorfloat(str_):
    """
    Try to cast a string as a ``bool``, ``float``, ``int``,
    or ``str_.__class__``.

    Args:
        str_ (basestring): string to try and cast
    Returns:
        object: casted ``{boot, float, int, or str_.__class__}``
    """
    match = re.match('([\d\.]+)', str_)
    type_ = None
    if not match:
        type_ = str_.__class__
        value = str_
        value_lower = value.strip().lower()
        if value_lower == 'true':
            type_ = bool
            value = True
        elif value_lower == 'false':
            type_ = bool
            value = False
        return value
    else:
        try:
            numstr = match.group(1)
            if '.' in numstr:
                type_ = float
                value = type_(numstr)
            else:
                type_ = int
                value = type_(numstr)
        except (__HOLE__, NameError, IndexError) as e:
            value = str_
            log.exception((e, (type_, value)))
    return value
dataset/ETHPy150Open westurner/pyline/pyline.py/str2boolintorfloat