pprintpp icon indicating copy to clipboard operation
pprintpp copied to clipboard

add sort_dicts option

Open gergelyk opened this issue 5 years ago • 6 comments

As regular dicts have guaranteed order from Python 3.7, it makes sense to add sort_dicts option as in case of pprint from the standard library.

gergelyk avatar Apr 21 '20 11:04 gergelyk

Hey! Thanks for the PR!

Two things:

  1. The default should be False on Py3 (as dicts are already ordered) and the documentation should reflect this
  2. Please add tests, including one which confirms that it will only sort dicts, not dict-like things like OrderedDict which already have an order.

wolever avatar Apr 23 '20 02:04 wolever

Hi. Thanks a million for your quick reply. Unfortunately I'm currently overloaded and may not be able to deliver this change. Let's forget about it. Sorry for bothering.

gergelyk avatar Apr 29 '20 22:04 gergelyk

Re 1. above, I actually think it should default to True (as is now) because that's the default value in Python 3.8 and if this package is to be a drop replacement o pprint, then keeping the default values should be observed.

joaonc avatar May 05 '20 01:05 joaonc

Came here looking for this functionality and found this issue. Is this still something that you would be interested in merging (if relevant tests were added?)

peter-malcolm-bw avatar Mar 29 '22 08:03 peter-malcolm-bw

Appears t work fine, would love to this this actually be in. Too bad there hasn't been any activity on this.

Sil3ntStorm avatar Apr 09 '22 01:04 Sil3ntStorm

IMO ideally sort_dicts would differ based on contextual use-case:

  • as ipython/repl default repr printer extension: should be False like default repl
  • called as a function after import: should be True like pprint

Kache avatar Jul 15 '22 20:07 Kache