Keys order in dictionaries

Ben Finney bignose-hates-spam at and-zip-does-too.com.au
Fri Jun 27 01:50:57 CEST 2003


On Fri, 27 Jun 2003 01:26:16 +0200, Brainwashed wrote:
> Is there any order in dictionaries that will never change ?

No.  The specification for the built-in dictionary type specifically
disclaims any preservation of order, to allow the implementation of any
arbitrary dictionary algorithm, with different, unpredictable (to the
user) storage and retrieval orders.

You can get ordered dictionaries (see the Python cookbook article
already pointed to), but not by directly using the built-in dictionary
type.

-- 
 \         "I have yet to see any problem, however complicated, which, |
  `\      when you looked at it in the right way, did not become still |
_o__)                             more complicated."  -- Paul Anderson |
http://bignose.squidly.org/ 9CFE12B0 791A4267 887F520C B7AC2E51 BD41714B




More information about the Python-list mailing list