[Tutor] Curious dictionary printing

Glen Zangirolami glenbot at gmail.com
Tue May 8 16:20:46 CEST 2012


Dictionaries do not sort in python because it's much faster to leave it
unordered and most of the time it isn't necessary.
If you really need ordered dictionaries you can use
http://pypi.python.org/pypi/ordereddict for Python <2.7. If you are using
python 2.7+ then you can import it from collections. See

Hope this helps.


On Tue, May 8, 2012 at 6:27 AM, Cranky Frankie <cranky.frankie at gmail.com>wrote:

> On Mon, May 7, 2012 at 10:31 PM, bob gailer <bgailer at gmail.com> wrote:
> > Asking why does it not do what I want is not IMHO the best way to win
> > friends here.
> Good morning to you to, Bob.
> I see now that dictionaries in Python act like relational databases in
> that there is no inherent ordering. At first, when I simply wanted to
> print one entry and it came out in what looked like a random order,
> this didn't occur to me. A normal "dictionary" is in fact ordered.
> Sorry for the disturbance.
> --
> Frank L. "Cranky Frankie" Palmeri
> Risible Riding Raconteur & Writer
> “The problem with quotes on the Internet is that
> it is often difficult to verify their authenticity.”
> - Abraham Lincoln
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20120508/18f26754/attachment.html>

More information about the Tutor mailing list