5.4. Sets
Python also includes a data type for sets. A set is an unordered collection with no duplicate elements. Basic uses include membership testing and eliminating duplicate entries. Set objects also support mathematical operations like union, intersection, difference, and symmetric difference.
Curly braces or the set() function can be used to create sets. Note: to create an empty set you have to use set(), not{}; the latter creates an empty dictionary, a data structure that we discuss in the next section. python3.3里面这样用。
Here is a brief demonstration:
Similarly to list comprehensions, set comprehensions are also supported: