On Tue, Oct 12, 2010 at 3:39 PM, Sander Sweers <sander.swe...@gmail.com>wrote:

> On 12 October 2010 21:15, Joel Goldstick <joel.goldst...@gmail.com> wrote:
> > When the dictionary is retrieved, its order depends on the hashed values
> > rather than the keys themself.
>
> If (big IF here) you really need an ordered dict you can use the
> OrderedDict from the collections module. However this will only
> guarantee *insertion* order (except for existing keys). Do make sure
> you read pep 372 [1].
>
> Greets
> Sander
>
> [1] http://www.python.org/dev/peps/pep-0372/
> _______________________________________________
>

It seems a common practice to create an ordered list of the keys, then
iterate over the list to operate on the dictionary.

-- 
Joel Goldstick
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to