Warning, this method is not guaranteed to be order-preserving. See http://docs.python.org/library/stdtypes.html#dict.items -- "CPython implementation detail: Keys and values are listed in an arbitrary order which is non-random, varies across Python implementations, and depends on the dictionarys history of insertions and deletions." -- Note it says "arbitrary" and it is implementation-dependent.
Comment
what about
dict(zip(seq,seq)).keys()
Replies
why on earth would you do that when you could do list(set(seq)) ??
Perhaps you would want the ordering?
This is absolutely ingenious! Thank you for sharing!
Warning, this method is not guaranteed to be order-preserving. See http://docs.python.org/library/stdtypes.html#dict.items -- "CPython implementation detail: Keys and values are listed in an arbitrary order which is non-random, varies across Python implementations, and depends on the dictionarys history of insertions and deletions." -- Note it says "arbitrary" and it is implementation-dependent.