MCPcopy Create free account
hub / github.com/ipython/ipython / _sorted_for_pprint

Function _sorted_for_pprint

IPython/lib/pretty.py:121–134  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

119 DeprecationWarning, stacklevel=2)
120
121def _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
136def pretty(obj, verbose=False, max_width=79, newline='\n', max_seq_length=MAX_SEQ_LENGTH):
137 """

Callers 1

innerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected