I have big dictionary which I`m printing for viewing with prettyprint, but how I can keep formatting but kill sorting mechanism in pprint?
I know that I am a bit late here but my preferred way to disable sorting dicts is by using partial
:
from functools import partial
from pprint import pprint
pprint = partial(pprint, sort_dicts=False)
Personally I like this way as it introduces the smallest diffs.
It has the benefit of monkey patching in that you only have to make changes at one spot(unlike other options) without having to mess with the internals of pprint
.
I'm using py3.8 but this should work from whenever sort_dicts
option was added.