<qiyuangong>008_String_to_Integer(atoi)_1.py
def myAtoi( str):
    sign = 1
    max_int, min_int = 2147483647, -2147483648
    result, pos = 0, 0
    ls = len(str)
    while pos < ls and str[pos] == ' ':
        pos += 1
    if pos < ls and str[pos] == '-':
        sign = -1
        pos += 1
    elif pos < ls and str[pos] == '+':
        pos += 1
    while pos < ls and ord(str[pos]) >= ord('0') and ord(str[pos]) <= ord('9'):
        num = ord(str[pos]) - ord('0')
        if result > max_int / 10 or ( result == max_int / 10 and num >= 8):
            if sign == -1:
                return min_int
            return max_int
        result = result * 10 + num
        pos += 1
    return sign * result
def sample_funcname ( var_0 ) :
    var_2 = 1
    var_4 , var_6 = 2147483647 , - 2147483648
    var_8 , var_9 = 0 , 0
    var_11 = len ( var_0 )
    while var_9 < var_11 and var_0 [ var_9 ] == ' ' :
        var_9 += 1
    if var_9 < var_11 and var_0 [ var_9 ] == '-' :
        var_2 = - 1
        var_9 += 1
    elif var_9 < var_11 and var_0 [ var_9 ] == '+' :
        var_9 += 1
    while var_9 < var_11 and ord ( var_0 [ var_9 ] ) >= ord ( '0' ) and ord ( var_0 [ var_9 ] ) <= ord ( '9' ) :
        var_18 = ord ( var_0 [ var_9 ] ) - ord ( '0' )
        if var_8 > var_4 / 10 or ( var_8 == var_4 / 10 and var_18 >= 8 ) :
            if var_2 == - 1 :
                return var_6
            return var_4
        var_8 = var_8 * 10 + var_18
        var_9 += 1
    return var_2 * var_8
