<div dir="ltr">I don't know if this clarifies anything, but I tried out such a mis-sorted example using the actual 'comm' tool<br><br><br><div>511-tmp % comm comm1 comm2</div><div><br></div><div><span class="" style="white-space:pre">          </span>A</div><div><span class="" style="white-space:pre">          </span>B</div><div>C</div><div>E</div><div>F</div><div>J</div><div>A</div><div>K</div><div><span class="" style="white-space:pre">  </span>M</div><div><span class="" style="white-space:pre">  </span>N</div><div><span class="" style="white-space:pre">          </span>T</div><div><span class="" style="white-space:pre">          </span>U</div><div><span class="" style="white-space:pre">          </span>V</div><div><br></div><div>512-tmp % cat comm[12]</div><div>A</div><div>B</div><div>C</div><div>E</div><div>F</div><div>J</div><div>A</div><div>K</div><div>T</div><div>U</div><div>V</div><div><br></div><div><br></div><div>A</div><div>B</div><div>M</div><div>N</div><div>T</div><div>U</div><div>V</div><div><br></div><div><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jan 7, 2015 at 10:20 AM, David Mertz <span dir="ltr"><<a href="mailto:mertz@gnosis.cx" target="_blank">mertz@gnosis.cx</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">Adding a itertools.comm() seems unnecessary, although adding it to the widely used more-itertools feels more reasonable.<div><br></div><div>However, the problem with the functionality is that it assumes that the iterables given to it return pre-sorted values.  Which is fine it that assumption is satisfied, but one really can't know in advance of exhausting the iterators whether that will prove true.  The desired behavior in the absence of this pre-condition being satisfied is unclear to me.</div><div><br></div><div>I could plausibly see the tool raising some exception when the pre-condition was violated.  Of course, in that case, we might well have already returned multiple elements on next(comm(it1, it2)) calls before the exception is encountered, and the initial values might be deceptive or retroactively invalidated.</div><div><br></div><div>I could plausibly see it ignoring the non-sorted elements in some way.  Maybe just pretend they are sorted rather than checking, returning somewhat ill-defined values, I'd think.  Or maybe just discarding the missorted values? Or flagging them with some other indicator indicating the missorting? I dunno.  </div><div><br></div><div>In any case, this is not something that can be applied to iterators generically, but only to iterators about which one makes lots of assumptions in advance, and hence seems ill-suited for the stdlib itertools.</div><div><br></div></div><div class="gmail_extra"><div><div class="h5"><br><div class="gmail_quote">On Wed, Jan 7, 2015 at 8:09 AM, Paul Moore <span dir="ltr"><<a href="mailto:p.f.moore@gmail.com" target="_blank">p.f.moore@gmail.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"><span>On 7 January 2015 at 15:38, Steven D'Aprano <<a href="mailto:steve@pearwood.info" target="_blank">steve@pearwood.info</a>> wrote:<br>
> This example of using comm in Unix might help:<br>
><br>
> <a href="http://www.theunixschool.com/2011/03/comm-beautiful-comparison.html" target="_blank">http://www.theunixschool.com/2011/03/comm-beautiful-comparison.html</a><br>
<br>
</span>The example on that page is the exact reason I wrote my own<br>
implementation (the Windows version of comm that I have locally got<br>
confused by non-ASCII content in some of the filenames I had).<br>
<span><font color="#888888"><br>
Paul<br>
</font></span><div><div>_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org" target="_blank">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" target="_blank">https://mail.python.org/mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" target="_blank">http://python.org/psf/codeofconduct/</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div></div></div><span class=""><font color="#888888">-- <br><div>Keeping medicines from the bloodstreams of the sick; food <br>from the bellies of the hungry; books from the hands of the <br>uneducated; technology from the underdeveloped; and putting <br>advocates of freedom in prisons.  Intellectual property is<br>to the 21st century what the slave trade was to the 16th.<br></div>
</font></span></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">Keeping medicines from the bloodstreams of the sick; food <br>from the bellies of the hungry; books from the hands of the <br>uneducated; technology from the underdeveloped; and putting <br>advocates of freedom in prisons.  Intellectual property is<br>to the 21st century what the slave trade was to the 16th.<br></div>
</div></div>