Skip to content

Instantly share code, notes, and snippets.

@phalt
Created December 7, 2017 13:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phalt/0c24844fa346f041a022fd45b6fe7d53 to your computer and use it in GitHub Desktop.
Save phalt/0c24844fa346f041a022fd45b6fe7d53 to your computer and use it in GitHub Desktop.
Python 3.6 ordered set using a Dict
'''
In python 3.6 dictionaries are ordered:
"The order-preserving aspect of this new implementation
is considered an implementation detail and should
not be relied upon."
But let's face it, we're going to use it and it is
going to become a consistent feature.
This is an example of using a Dict to act like an OrderedSet - ordered, unique values.
It's way cooler than the standard old `OrderedDict` type.
'''
my_dict = {'A unique value': None, 'another unique value': None}
list(my_dict.keys())
['A unique value', 'another unique value']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment