Importing Sets in python
Question: When I am trying to use sets it's showing that there is nothing named set.

    
    
    from sets import set
    
    > ImportError: cannot import name set
    

How do I fix it?


Answer: You don't _need_ to import the [`sets`
module](http://docs.python.org/2/library/sets.html); sets are built in now.
Just use the built-in [`set()`
type](http://docs.python.org/2/library/stdtypes.html#set-types-set-frozenset)
instead:

    
    
    >>> set()
    set([])
    

You can use the `{1, 2, 3}` set literal syntax too:

    
    
    >>> {1, 2, 3}
    set([1, 2, 3])
    

If you want to use the slower `sets` module anyway, the object is called `Set`
with a capital `S`:

    
    
    >>> from sets import Set
    

but note that the module has been deprecated; using it does not add anything
over the built-in types. The module has been removed altogether in Python 3.

