Spir sent this solely to me by accident, I think.
---------- Forwarded message ---------- From: spir ☣ <denis.s...@gmail.com> Date: 2010/4/19 Subject: Re: [Tutor] List index usage: is there a more pythonesque way? To: cmca...@googlemail.com On Mon, 19 Apr 2010 12:59:40 +0100 C M Caine <cmca...@googlemail.com> wrote: > That's the first I've read of iterating through dictionaries, I'd > assumed it was impossible because they're unordered. Hem, actually "ordered" and "unordered" mean whether the order is meaningful or not. There are at least 2 implicit orders for each collection: * There order in which they where put in. * The order in which they iterated. But these can be meaningless, in the sense of arbitrary, like the alphabetic order. As an example, consider a 'friends' collections: * If it's just a group of friends, then it's unordered and maps to a set data structure in python (and computer science, and maths). * If they are put in the collection eg by favor (best friend first or last), then it's an ordered *sequence*, and maps to a list data structure in python (and numerous other languages). As a consequence, precisely because order is meaningful, another difference is a sequence can hold several times the same item, while it makes no sense for a set. [The choice of the term "list" is imo rather misleading. Eg a shopping list does not mean one must buy the items in order ;-)] 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