<div dir="ltr">Use case not relevant enough for you? <div class="gmail_extra"><br><div class="gmail_quote">On Tue, Oct 7, 2014 at 3:40 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">I think I just lost interest in this thread.<br></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Oct 6, 2014 at 1:41 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"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span>On Mon, Oct 6, 2014 at 8:35 PM, 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:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span>On Mon, Oct 6, 2014 at 1:10 AM, 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:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><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></blockquote><div><br></div></span><div>So how are you writing this code today? In the following case, what's in the then or else branch?<br><br>if not isinstance(x, collections.Ordered):<br></div><div>    <what???><br></div><div>else:<br></div><div>    <what???><br><br></div><div>Even if you could write this, how would you know that an ordered argument is in the *canonical* order?<br></div></div></div></div></blockquote><div><br></div></span><div>That part isn't written yet (the package is still work-in-progress), but I'm not sure what the problem is. I'll have the code look at `x`. If it's marked as ordered, then I'd iterate on it. If it has the correct items (meaning the items of the sequence that this is a combination space of) and the items in x are in the same order as they are in the sequence, and it has the correct number of items, then we have a match. If we have `not isinstance(x, collections.Ordered)` then I do the same thing except I ignore the order of the items. What's the problem? </div><span><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div></div><span><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><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></blockquote><div><br></div></span><div>Same question.<br><br></div></div><span>-- <br>--Guido van Rossum (<a href="http://python.org/~guido" target="_blank">python.org/~guido</a>)
</span></div></div>
</blockquote></span></div><br></div></div>
</blockquote></div><br><br clear="all"><br>-- <br>--Guido van Rossum (<a href="http://python.org/~guido" target="_blank">python.org/~guido</a>)
</div>
</div></div></blockquote></div><br></div></div>