New submission from Vedran Čačić <ved...@gmail.com>:

I'm sure this is exactly how it should work, I just want to know if you think 
it is documented properly, so I can rely on it. In my opinion the docs should 
be more precise.

>>> ''.join(dict.fromkeys('axbxc'))
'axbc'

Is this guaranteed by the documentation? Of course, dict iteration order is now 
guaranteed to be insertion order, but still, nowhere do the docs say that 
fromkeys inserts the keys into new dictionary in order in which they appear in 
its argument.

(Probably the reason for this is that dict iteration order was fixed in 3.7, 
yet fromkeys existed a long time before that.)

I propose an addition to the documentation:

> Create a new dictionary with keys from iterable (in order) and values set to 
> value.

https://docs.python.org/3/library/stdtypes.html

----------
assignee: docs@python
components: Documentation
messages: 407136
nosy: docs@python, veky
priority: normal
severity: normal
status: open
title: dict.fromkeys insertion order
versions: Python 3.10, Python 3.11

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue45908>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to