A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2017-November/150286.html below:

[Python-Dev] Guarantee ordered dict literals in v3.7?

[Python-Dev] Guarantee ordered dict literals in v3.7? [Python-Dev] Guarantee ordered dict literals in v3.7?Nick Coghlan ncoghlan at gmail.com
Tue Nov 7 01:23:05 EST 2017
On 7 November 2017 at 03:27, Chris Jerdonek <chris.jerdonek at gmail.com> wrote:
> On Mon, Nov 6, 2017 at 4:11 AM Nick Coghlan <ncoghlan at gmail.com> wrote:
>> Getting from the "Works on CPython 3.6+ but is technically
>> non-portable" state to a fully portable correct implementation that
>> ensures a particular key order in the JSON file thus currently
>> requires the following changes:
>
> Nick, it seems like this is more complicated than it needs to be. You can
> just pass sort_keys=True to json.dump() / json.dumps(). I use it for tests
> and human-readability all the time.

sort_keys is only equivalent to order preservation if the key order
you want *is* alphabetical order. While that's typically a good enough
assumption for JSON, it's not the case for things like CSV column
order, TOML or ini-file setting order, etc.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4