Exemple #1
0
def to_bool(s):
    """Coerce string s to a bool."""
    if s == 'True':
        return True
    if s == 'False':
        return False
    raise logo.error(str(s) + ' is not a boolean value')
def to_bool(s):
    """Coerce string s to a bool."""
    if s == 'True':
        return True
    if s == 'False':
        return False
    raise logo.error(str(s) + ' is not a boolean value')
Exemple #3
0
def to_num(s):
    """Coerce string s to a number."""
    try:
        return int(s)
    except (TypeError, ValueError):
        try:
            return float(s)
        except (TypeError, ValueError):
            raise logo.error(str(s) + ' is not a number')
def to_num(s):
    """Coerce string s to a number."""
    try:
        return int(s)
    except (TypeError, ValueError):
        try:
            return float(s)
        except (TypeError, ValueError):
            raise logo.error(str(s) + ' is not a number')