[Tutor] List index usage: is there a more pythonesque way?

Alan Gauld alan.gauld at btinternet.com
Mon Apr 19 16:23:00 CEST 2010

"C M Caine" <cmcaine at googlemail.com> wrote 

> That's the first I've read of iterating through dictionaries, I'd
> assumed it was impossible because they're unordered. 

Iteration doesn't require order, only to get each item once.
Even in very old Python versions you could iterate a dictionary 
via the keys() method. More recently you can do it directly - although 
the effect is the same. There is no guarantee of order only that 
you process every item once.

Alan Gauld
Author of the Learn to Program web site

More information about the Tutor mailing list