def _tuple_repr(data): """Return a repr() for a list/tuple""" if len(data) == 1: return "(%s,)" % rpr(data[0]) else: return "(%s)" % ", ".join([rpr(x) for x in data])
def _stable_dict_repr(strdict): """Return a repr() for a dict keyed by a string, in sorted key order""" lines = [] for key in sorted(strdict.keys()): lines.append("'%s': %s" % (key, rpr(strdict[key]))) return "{%s}" % ", ".join(lines)