The Python Oracle

Do Python dict literals and dict(list of pairs) keep their key order?

Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn

--

Music by Eric Matyas
https://www.soundimage.org
Track title: Mysterious Puzzle

--

Chapters
00:00 Question
01:20 Accepted answer (Score 6)
02:59 Thank you

--

Full question
https://stackoverflow.com/questions/6387...

Question links:
[thread in the Python mailing list]: https://mail.python.org/pipermail/python...
[other naturally ordered constructions]: https://docs.python.org/3/tutorial/datas...
[dictionaries preserve insertion order]: https://docs.python.org/3.7/whatsnew/3.7...

Accepted answer links:
[documentation]: https://docs.python.org/3/reference/expr...
[Martijn's answer]: https://stackoverflow.com/a/39537308/451...
[How to keep keys/values in same order as declared?]: https://stackoverflow.com/q/1867861/4518...
[same source]: https://docs.python.org/3/reference/expr...
[dict]: https://docs.python.org/3/library/stdtyp...
[source code]: https://github.com/python/cpython/blob/v...
[keyword arguments pass a dictionary ]: https://docs.python.org/3/whatsnew/3.6.h...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #dictionary #literals

#avk47