def to_number(n):''' Convert any number representation to a numberThis covers: float, decimal, hex, and octal numbers.'''
try:return int(str(n), 0)except:try:# python 3 doesn't accept "010" as a valid octal. You must use the# '0o' prefixreturn int('0o' + n, 0)except:return float(n)