def str2float( s ):
'''A function used for invert str to float.'''
def to_num( s ):
# The ASCII codec for '.' is 0x2E, namely 46(radix 10).
return {'0':0, '1':1, '2':2, '3':3, '4':4, '5':5, '6':6, '7':7,'8':8, '9':9, '.':46}[s]
# i is used for counting numbers which is larger than 1.
i = 0
L = list( map( tonum, s ) )
for x in L:
i = i + 1
if x == 46:
break
print(L.remove(46))
return reduce( lambda x, y: x * 10 + y, L ) / 10 **(len(L) - i + 1)
witnessus