コード例 #1
0
ファイル: logo_primitives.py プロジェクト: dkfywq/Logo
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')
コード例 #2
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')
コード例 #3
0
ファイル: logo_primitives.py プロジェクト: dkfywq/Logo
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')
コード例 #4
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')