summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>1999-02-17 17:30:52 (GMT)
committerFred Drake <fdrake@acm.org>1999-02-17 17:30:52 (GMT)
commitd804f4eea0c9831082bd267133f6c2e8cd0101ca (patch)
treec2192a652bd07c682ee0ced914896ed9b4067641
parentc4f752f803a20948826eff4601ea595d8b74bb96 (diff)
downloadcpython-d804f4eea0c9831082bd267133f6c2e8cd0101ca.zip
cpython-d804f4eea0c9831082bd267133f6c2e8cd0101ca.tar.gz
cpython-d804f4eea0c9831082bd267133f6c2e8cd0101ca.tar.bz2
_safe_repr(): Simplify the condition tests in the first possible
return path.
-rw-r--r--Lib/pprint.py9
1 files changed, 2 insertions, 7 deletions
diff --git a/Lib/pprint.py b/Lib/pprint.py
index fcf0904..fdfdc43 100644
--- a/Lib/pprint.py
+++ b/Lib/pprint.py
@@ -187,20 +187,15 @@ class PrettyPrinter:
def _safe_repr(object, context, maxlevels=None, level=0):
level = level + 1
- readable = 1
typ = type(object)
if not (typ in (DictType, ListType, TupleType) and object):
rep = `object`
- if rep:
- if rep[0] == '<':
- readable = 0
- else:
- readable = 0
- return `object`, readable
+ return rep, (rep and (rep[0] != '<'))
if context.has_key(id(object)):
return `_Recursion(object)`, 0
objid = id(object)
context[objid] = 1
+ readable = 1
if typ is DictType:
if maxlevels and level >= maxlevels:
s = "{...}"