Is there a canonical way to check whether an iterable is ordered?
rosuav at gmail.com
Fri Sep 19 14:36:59 CEST 2014
On Fri, Sep 19, 2014 at 10:26 PM, alister
<alister.nospam.ware at ntlworld.com> wrote:
> As far as I understand it the order of keys in a dict is not guaranteed
> iterating over the same dict twice (without changes) does not have to
> return the keys in the same order.
The exact guarantee is that you can iterate over keys() followed by
values() and they will correspond. This implies (in the strict logical
sense of the word "implies", as well as the common sense of the same
word) that iterating multiple times over keys() will correspond, which
is the point I drew above.
More information about the Python-list