From: Fred Drake Date: Wed, 17 Feb 1999 17:30:52 +0000 (+0000) Subject: _safe_repr(): Simplify the condition tests in the first possible X-Git-Tag: v1.5.2b2~16 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d804f4eea0c9831082bd267133f6c2e8cd0101ca;p=python _safe_repr(): Simplify the condition tests in the first possible return path. --- diff --git a/Lib/pprint.py b/Lib/pprint.py index fcf09046c8..fdfdc4395f 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 = "{...}"