Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
undup
#5
Assuming that objective is to dedupe hashable objects in iterable while maintaining order:


def dedupe(iterable):
    seen = set()
    for item in iterable:
        if item not in seen:
            yield item
            seen.add(item)
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply


Messages In This Thread
undup - by Skaperen - May-10-2019, 06:56 AM
RE: undup - by buran - May-10-2019, 07:15 AM
RE: undup - by buran - May-10-2019, 07:16 AM
RE: undup - by Skaperen - May-10-2019, 11:49 PM
RE: undup - by perfringo - May-11-2019, 05:43 AM
RE: undup - by Skaperen - May-12-2019, 08:23 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020