diff options
author | Raymond Hettinger <python@rcn.com> | 2004-05-21 23:01:18 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2004-05-21 23:01:18 (GMT) |
commit | 1453e4aa7587898954acc49e7680a9d65c5d2c74 (patch) | |
tree | 924d4ba5074803fdd5eca5169767ed500981e842 /Lib/repr.py | |
parent | ba6cd3647ff5bd0415dcdb4649a5e6a7a88c0e72 (diff) | |
download | cpython-1453e4aa7587898954acc49e7680a9d65c5d2c74.zip cpython-1453e4aa7587898954acc49e7680a9d65c5d2c74.tar.gz cpython-1453e4aa7587898954acc49e7680a9d65c5d2c74.tar.bz2 |
* teach repr.repr() about collections.deque()
* rename a variable for clarity
Diffstat (limited to 'Lib/repr.py')
-rw-r--r-- | Lib/repr.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Lib/repr.py b/Lib/repr.py index a137306..7c0016b 100644 --- a/Lib/repr.py +++ b/Lib/repr.py @@ -15,6 +15,7 @@ class Repr: self.maxdict = 4 self.maxset = 6 self.maxfrozenset = 6 + self.maxdeque = 6 self.maxstring = 30 self.maxlong = 40 self.maxother = 20 @@ -37,7 +38,7 @@ class Repr: s = s[:i] + '...' + s[len(s)-j:] return s - def _repr_iterable(self, x, level, left, right, maxiter, final=''): + def _repr_iterable(self, x, level, left, right, maxiter, trail=''): n = len(x) if level <= 0 and n: s = '...' @@ -47,7 +48,7 @@ class Repr: pieces = [repr1(elem, newlevel) for elem in islice(x, maxiter)] if n > maxiter: pieces.append('...') s = ', '.join(pieces) - if n == 1 and final: s += final + if n == 1 and trail: right = trail + right return '%s%s%s' % (left, s, right) def repr_tuple(self, x, level): @@ -67,6 +68,9 @@ class Repr: return self._repr_iterable(x, level, 'frozenset([', '])', self.maxfrozenset) + def repr_deque(self, x, level): + return self._repr_iterable(x, level, 'deque([', '])', self.maxdeque) + def repr_dict(self, x, level): n = len(x) if n == 0: return '{}' |