sidpy/base/string_utils.py
def str_to_other(value):
    """
    Casts a single value encoded in a string to the appropriate python object.
    Useful when parsing numbers, boolean, etc. in text files

    Parameters
    ----------
    value : str / unicode
        String to be casted into other appropriate python object
    """
    if not isinstance(value, (str, unicode)):
        raise TypeError('Expected object of type str. Provided object was: {}'
                        ''.format(type(value)))
    if len(value.split(' ')) > 1:
        raise ValueError('Expected a string without spaces. Got: "{}"'
                         ''.format(value))
    value = value.strip()
    try:
        return int(value)
    except ValueError:
        try:
            return float(value)
        except ValueError:
            if value.lower() == 'true':
                value = True
            elif value.lower() == 'false':
                value = False
            return value

    Casts a single value encoded in a string to the appropriate python object.
    Useful when parsing numbers, boolean, etc. in text files

    Parameters
    ----------
    value : str / unicode
        String to be casted into other appropriate python object
    
Casts a single value encoded in a string to the appropriate python object.
Useful when parsing numbers, boolean, etc. in text files

Parameters

value : str / unicode
String to be casted into other appropriate python object
Casts a single value encoded in a string to the appropriate python object . Useful when parsing numbers boolean etc . in text files Parameters value : str / unicode String to be casted into other appropriate python object
def str_to_other(value):
    if not isinstance(value, (str, unicode)):
        raise TypeError('Expected object of type str. Provided object was: {}'
                        ''.format(type(value)))
    if len(value.split(' ')) > 1:
        raise ValueError('Expected a string without spaces. Got: "{}"'
                         ''.format(value))
    value = value.strip()
    try:
        return int(value)
    except ValueError:
        try:
            return float(value)
        except ValueError:
            if value.lower() == 'true':
                value = True
            elif value.lower() == 'false':
                value = False
            return value
def str_to_other ( value ) : if not isinstance ( value , ( str , unicode ) ) : raise TypeError ( 'Expected object of type str. Provided object was: {}' '' . format ( type ( value ) ) ) if len ( value . split ( ' ' ) ) > 1 : raise ValueError ( 'Expected a string without spaces. Got: "{}"' '' . format ( value ) ) value = value . strip ( ) try : return int ( value ) except ValueError : try : return float ( value ) except ValueError : if value . lower ( ) == 'true' : value = True elif value . lower ( ) == 'false' : value = False return value
Casts a single value encoded in a string to the appropriate python object.
Casts a single value encoded in a string to the appropriate python object .
"""
    Casts a single value encoded in a string to the appropriate python object.
    Useful when parsing numbers, boolean, etc. in text files

    Parameters
    ----------
    value : str / unicode
        String to be casted into other appropriate python object
    """
value