Skip to content

Instantly share code, notes, and snippets.

@dangayle
Created October 29, 2014 03:56
Show Gist options
  • Save dangayle/fc2b75ca703d451c98f1 to your computer and use it in GitHub Desktop.
Save dangayle/fc2b75ca703d451c98f1 to your computer and use it in GitHub Desktop.
unique list
from collections import OrderedDict
from itertools import repeat, izip
alist = ["a", "b", "c", "a"]
n = repeat(None)
print(list(OrderedDict(izip(alist,n))))
@dangayle
Copy link
Author

Or even better:
sorted(set(alist), key=lambda x: alist.index(x))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment