Mercurial > cpython-lru_cache-weakref
diff Lib/pprint.py @ 6312:7ba79c949b3a legacy-trunk
Added code to emit trailing ',' for singleton tuples in two places.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Sun, 14 Sep 1997 23:21:51 +0000 |
| parents | 2e917f9372e0 |
| children | fb4b4d069cc7 |
line wrap: on
line diff
--- a/Lib/pprint.py Sat Sep 13 00:44:23 1997 +0000 +++ b/Lib/pprint.py Sun Sep 14 23:21:51 1997 +0000 @@ -147,6 +147,8 @@ self.__format(ent, stream, indent, allowance + 1, context, level) indent = indent - self.__indent_per_level + if typ is TupleType and length == 1: + stream.write(',') stream.write(((typ is ListType) and ']') or ')') elif sepLines and typ is DictType: @@ -226,7 +228,11 @@ object[0], context, maxlevels, level) readable = readable and subreadable s = s + subrepr - for ent in object[1:]: + tail = object[1:] + if not tail: + if typ is TupleType: + s = s + ',' + for ent in tail: subrepr, subreadable = _safe_repr( ent, context, maxlevels, level) readable = readable and subreadable
