Sort the given items for pretty printing. Since some predictable sorting is better than no sorting at all, we sort on the string representation if normal sorting fails.
(items)
| 119 | DeprecationWarning, stacklevel=2) |
| 120 | |
| 121 | def _sorted_for_pprint(items): |
| 122 | """ |
| 123 | Sort the given items for pretty printing. Since some predictable |
| 124 | sorting is better than no sorting at all, we sort on the string |
| 125 | representation if normal sorting fails. |
| 126 | """ |
| 127 | items = list(items) |
| 128 | try: |
| 129 | return sorted(items) |
| 130 | except Exception: |
| 131 | try: |
| 132 | return sorted(items, key=str) |
| 133 | except Exception: |
| 134 | return items |
| 135 | |
| 136 | def pretty(obj, verbose=False, max_width=79, newline='\n', max_seq_length=MAX_SEQ_LENGTH): |
| 137 | """ |