cpython: d48ac94e365f (original) (raw)
Mercurial > cpython
changeset 85931:d48ac94e365f
Use cached builtins.
Serhiy Storchaka storchaka@gmail.com | |
---|---|
date | Wed, 02 Oct 2013 19:15:54 +0300 |
parents | d90f25e1a705 |
children | 6e7b1aadea2f |
files | Lib/pprint.py |
diffstat | 1 files changed, 6 insertions(+), 6 deletions(-)[+] [-] Lib/pprint.py 12 |
line wrap: on
line diff
--- a/Lib/pprint.py +++ b/Lib/pprint.py @@ -96,8 +96,8 @@ class _safe_key: rv = NotImplemented if rv is NotImplemented:
rv = (str(type(self.obj)), id(self.obj)) < \[](#l1.7)
(str(type(other.obj)), id(other.obj))[](#l1.8)
rv = (str(_type(self.obj)), _id(self.obj)) < \[](#l1.9)
(str(_type(other.obj)), _id(other.obj))[](#l1.10) return rv[](#l1.11)
def _safe_tuple(t): @@ -225,7 +225,7 @@ class PrettyPrinter: write(typ.name) write('({') endchar = '})'
indent += len(typ.__name__) + 1[](#l1.18)
indent += _len(typ.__name__) + 1[](#l1.19) object = sorted(object, key=_safe_key)[](#l1.20) if self._indent_per_level > 1:[](#l1.21) write((self._indent_per_level - 1) * ' ')[](#l1.22)
@@ -240,7 +240,7 @@ class PrettyPrinter: write(endchar) return
if issubclass(typ, str) and len(object) > 0 and r is str.__repr__:[](#l1.27)
if issubclass(typ, str) and _len(object) > 0 and r is str.__repr__:[](#l1.28) def _str_parts(s):[](#l1.29) """[](#l1.30) Return a list of string literals comprising the repr()[](#l1.31)
@@ -255,10 +255,10 @@ class PrettyPrinter: # A list of alternating (non-space, space) strings parts = re.split(r'(\s+)', line) + [''] current = ''
for i in range(0, len(parts), 2):[](#l1.36)
for i in range(0, _len(parts), 2):[](#l1.37) part = parts[i] + parts[i+1][](#l1.38) candidate = current + part[](#l1.39)
if len(repr(candidate)) > max_width:[](#l1.40)
if _len(repr(candidate)) > max_width:[](#l1.41) if current:[](#l1.42) yield repr(current)[](#l1.43) current = part[](#l1.44)