<div dir="ltr">Here are a couple:<div><br></div><div> - I'm making a combinatorics package, and a combination space needs to have a __contains__ method that takes a combination and returns whether it's part of a set. Since a combination, unlike a permutation, has no order, I like to have my combinations be canonicalized in a sorted order. For example, in a combination space of 3 items on range(4), (0, 1, 3) would be a combination in that space, but (3, 1, 0) would not because it's not sorted. (It's a k-permutation but not a combination.) However, if the user does `{0, 1, 3} in comb_space` I still want to return True, regardless of whether the set iterator happens to give these items in order or not. </div><div><br></div><div> - For the same package, I'm defining `Tally` and `OrderedTally` classes. (Simliar to `Counter` except without having an identity crisis between being a dict subclass and counter; mine are strictly counters.) In the tests I want to easily see whether the class I'm testing is the ordered one or not, so I'll know to run appropriate tests. (There are also `FrozenTally` and `FrozenOrderedTally` so it's not just one class.) I could set `is_ordered = True` on them or give them some base class, but I think a general `collections.Ordered` abstract base class would be the best solution.</div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Oct 6, 2014 at 2:15 AM, Guido van Rossum <span dir="ltr"><<a href="mailto:guido@python.org" target="_blank" onclick="window.open('https://mail.google.com/mail/?view=cm&tf=1&to=guido@python.org&cc=&bcc=&su=&body=','_blank');return false;">guido@python.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>OK, so collections.Ordered would be a subclass of Iterable that adds no new methods but makes a
promise about the author's intent.<br><br>But what kind of use could a program
make of this? The only things I can think of would have to be combined
with some other specific container type that isn't always ordered
(Sequence is ordered, Set and Mapping aren't). I can think of plenty of
situations where it would be useful to say "use an OrderedDict,
otherwise X will happen", but I can't think of a case where I could say
"use any container type you like as long as it is Ordered".<br><br></div>What was your use case? Do you have one? Or are you just interested in asking questions?<br></div><div class="gmail_extra"><div><div class="h5"><br><div class="gmail_quote">On Sun, Oct 5, 2014 at 3:07 PM, Ram Rachum <span dir="ltr"><<a href="mailto:ram@rachum.com" target="_blank" onclick="window.open('https://mail.google.com/mail/?view=cm&tf=1&to=ram@rachum.com&cc=&bcc=&su=&body=','_blank');return false;">ram@rachum.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">Yep, Ed said exactly what I meant.</p><div><div>
<div class="gmail_quote">On Oct 6, 2014 1:05 AM, "Ed Kellett" <<a href="mailto:edk141@gmail.com" target="_blank" onclick="window.open('https://mail.google.com/mail/?view=cm&tf=1&to=edk141@gmail.com&cc=&bcc=&su=&body=','_blank');return false;">edk141@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I think the definition of ordered here would be that the container's<br>
iteration order carries any meaning (compare: dicts and sets' having<br>
iteration order is an incidental effect of one thing having to be<br>
iterated out first, and one shouldn't depend on that order; lists and<br>
ordereddicts' having iteration order is deliberate).<br>
<br>
I don't think there's a mathematical definition possible - it's just a<br>
question of whether whoever wrote the class left the iteration order<br>
documented or unspecified.<br>
<br>
<br>
edk<br>
</blockquote></div>
</div></div></blockquote></div><br><br clear="all"><br></div></div><span class="">-- <br>--Guido van Rossum (<a href="http://python.org/~guido" target="_blank">python.org/~guido</a>)
</span></div>
</blockquote></div><br></div></div></div></div>