diff options
Diffstat (limited to 'Lib/decimal.py')
-rw-r--r-- | Lib/decimal.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Lib/decimal.py b/Lib/decimal.py index 1f5ff12962..434930ad32 100644 --- a/Lib/decimal.py +++ b/Lib/decimal.py @@ -137,6 +137,12 @@ __all__ = [ import numbers as _numbers import copy as _copy +try: + from collections import namedtuple as _namedtuple + DecimalTuple = _namedtuple('DecimalTuple', 'sign digits exponent') +except ImportError: + DecimalTuple = lambda *args: args + # Rounding ROUND_DOWN = 'ROUND_DOWN' ROUND_HALF_UP = 'ROUND_HALF_UP' @@ -841,7 +847,7 @@ class Decimal(_numbers.Real, _numbers.Inexact): To show the internals exactly as they are. """ - return (self._sign, tuple(map(int, self._int)), self._exp) + return DecimalTuple(self._sign, tuple(map(int, self._int)), self._exp) def __repr__(self): """Represents the number as an instance of Decimal.""" |