[Python-ideas] list…pushed, or something
Bruce Leban
bruce at leapyear.org
Thu Mar 28 06:28:41 CET 2013
On Wed, Mar 27, 2013 at 10:11 PM, Shane Green <shane at umbrellacode.com>wrote:
> [seen.added(value) for value in sequence if value not in seen] *
>
Here's an easy way to do it:
>>> seen = set()
>>> seq = [3,2,1,2,3,4,5,4]
>>> [seen.add(v) or v for v in seq if v not in seen]
[3, 2, 1, 4, 5]
>>> seen
{1, 2, 3, 4, 5}
--- Bruce
Latest blog post: Alice's Puzzle Page http://www.vroospeak.com
Learn how hackers think: http://j.mp/gruyere-security
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130327/86d9c224/attachment.html>
More information about the Python-ideas
mailing list