On Thu, 27 May 2010 20:00:46 -0600 Matthew Wood <woodm1...@gmail.com> wrote:
> I THOUGHT the guaranteed same-ordering of dict.keys and dict.values started > in python 2.6. That was a simple mistake. > > It turns out, that's not the case. But in general, access to dicts and sets > is unordered, so you can't/don't/shouldn't count on ordering. The solution > to take keys and values from dict.items() DOES guarantee their ordering, > even if dict.keys and dict.values aren't. The word "order" is a bit over-used :-) Python's guarantee is that the *output* orders of keys() & value() match each other. Say, they're consistent // sequences. This is a different feature from preserving *input* order of of keys, or of key:value pairs. (Which is not true is Python or Lua, for instance, but in recent Ruby versions, yes: http://www.igvita.com/2009/02/04/ruby-19-internals-ordered-hash/.) Denis ________________________________ vit esse estrany ☣ spir.wikidot.com _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor