<br><br><div class="gmail_quote">On 16 November 2012 12:39, 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:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5">On 16 November 2012 12:28, Robrecht De Rouck <span dir="ltr"><<a href="mailto:de.rouck.robrecht@gmail.com" target="_blank">de.rouck.robrecht@gmail.com</a>></span> wrote:<br><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello,<div><br></div><div>I just wanted to bring to your attention that an <b>attribute for removing duplicate elements</b> for lists would be a nice feature. </div><div><br></div><i>def uniquify(lis):<br>    seen = set()<br>


    seen_add = seen.add<br>    return [ x for x in lis if x not in seen and not seen_add(x)]</i><div><i><br></i></div><div>The code is from <a href="http://stackoverflow.com/questions/480214/how-do-you-remove-duplicates-from-a-list-in-python-whilst-preserving-order" target="_blank">this post</a>. Also check out <a href="http://www.peterbe.com/plog/uniqifiers-benchmark" target="_blank">this performance comparison</a> of uniquifying snippets.</div>


<div>It would be useful to have a uniquify attribute for containers in general. </div><div></div></blockquote></div><br><div><br></div></div></div><div>list(set(ls))</div></blockquote><div><br></div><div>This loses order. Both solutions suffer from the problem that they only work with hashable objects.</div>
<div><br></div><div>Michael</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="HOEnZb"><font color="#888888"><div><br></div><div>Paul</div>
</font></span><br>_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/python-ideas" target="_blank">http://mail.python.org/mailman/listinfo/python-ideas</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><pre cols="72"><a href="http://www.voidspace.org.uk/" target="_blank">http://www.voidspace.org.uk/</a><br><br>May you do good and not evil<br>May you find forgiveness for yourself and forgive others<br>
May you share freely, never taking more than you give.<br>-- the sqlite blessing <a href="http://www.sqlite.org/different.html" target="_blank">http://www.sqlite.org/different.html</a></pre>
<br>