Kaydet (Commit) 097a1903 authored tarafından Raymond Hettinger's avatar Raymond Hettinger

Have Decimal.as_tuple return a named tuple.

üst a7d984e8
......@@ -136,6 +136,12 @@ __all__ = [
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'
......@@ -820,7 +826,7 @@ class Decimal(object):
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."""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment