Alternatively, you can do this with a decimal module:
>>> from decimal import Decimal >>> Decimal(123).as_tuple() DecimalTuple(sign=0, digits=(1, 2, 3), exponent=0) >>> Decimal(123).as_tuple().digits (1, 2, 3)
... which also works with real numbers ...
>>> Decimal(1.1).as_tuple() DecimalTuple(sign=0, digits=(1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 8, 8, 1, 7, 8, 4, 1, 9, 7, 0, 0, 1, 2, 5, 2, 3, 2, 3, 3, 8, 9, 0, 5, 3, 3, 4, 4, 7, 2, 6, 5, 6, 2, 5), exponent=-51) >>> Decimal('1.1').as_tuple() DecimalTuple(sign=0, digits=(1, 1), exponent=-1)