Use frozenset,
>>> set([frozenset([1,2]), frozenset([2,3])]) set([frozenset([1, 2]), frozenset([2, 3])])
To represent a set of sets, the inner sets must be frozenset objects for the reason that the elements of a set must be hashable (all of Python’s immutable built-in objects are hashable). frozenset
is immutable and set
is mutable.
Related Posts:
- Add list to set?
- Python set to list
- Remove list from list in Python
- TypeError: unsupported operand type(s) for -: ‘list’ and ‘list’
- Python Sets vs Lists
- Inorder Binary Tree Traversal (using Python)
- In Python, when to use a Dictionary, List or Set?
- Type error Unhashable type:set
- How to make a set of lists
- How to obtain a subarray in python 3
- Get difference between two lists
- How can I reverse a list in Python?
- How can I reverse a list in Python?
- What is the difference between Python’s list methods append and extend?
- Understanding slice notation
- How to convert list to string [duplicate]
- Finding the index of an item in a list
- working of \n in python [duplicate]
- Pip freeze vs. pip list
- List changes unexpectedly after assignment. Why is this and how can I prevent it?
- Cannot find module cv2 when using OpenCV
- TypeError: ‘float’ object is not subscriptable
- Is there a short contains function for lists?
- appending list but error ‘NoneType’ object has no attribute ‘append’
- sklearn error ValueError: Input contains NaN, infinity or a value too large for dtype(‘float64’)
- TypeError: cannot perform reduce with flexible type
- Does Python have an ordered set?
- ImportError: numpy.core.multiarray failed to import
- Print a list in reverse order with range()?
- Why is it string.join(list) instead of list.join(string)?
- Finding median of list in Python
- ImportError: numpy.core.multiarray failed to import
- Python List vs. Array – when to use?
- How to remove \xa0 from string in Python?
- What is the meaning of [:] in python [duplicate]
- Finding and replacing elements in a list
- ValueError: max() arg is an empty sequence
- Unzip all zipped files in a folder to that same folder using Python 2.7.5
- python socket.error: [Errno 98] Address already in use
- Writing a list to a file with Python
- Understanding slice notation
- What’s the idiomatic syntax for prepending to a short python list?
- How to remove an element from a list by index
- Apply function to each element of a list
- Creating 2D dictionary in Python
- How do I append lists in Prolog?
- TypeError: list indices must be integers or slices, not str
- Checking whether pip is installed?
- Decoding UTF-8 strings in Python
- How to have an array of arrays in Python
- ‘list’ object has no attribute ‘shape’
- How do I find the duplicates in a list and create another list with them?
- How do I check if a list is empty?
- How can I get list of values from dict?
- IndexError: list index out of range and python
- AttributeError: ‘list’ object has no attribute ‘replace’ when trying to remove character
- How to sort a list of objects based on an attribute of the objects?
- AttributeError: ‘list’ object has no attribute ‘replace’ when trying to remove character
- ValueError: unsupported pickle protocol: 3, python2 pickle can not load the file dumped by python 3 pickle?
- ValueError: unsupported pickle protocol: 3, python2 pickle can not load the file dumped by python 3 pickle?
- AttributeError(“‘str’ object has no attribute ‘read'”)
- How to iterate through two lists in parallel?
- How to remove \n from a list element?
- Why does using from __future__ import print_function breaks Python2-style print?
- How to return dictionary keys as a list in Python?
- Python Error – int object has no attribute
- Loading a file with more than one line of JSON into Pandas
- Defining lists as global variables in Python
- Subtracting two lists in Python
- How to concatenate items in a list to a single string?
- Python 2: AttributeError: ‘list’ object has no attribute ‘strip’
- matplotlib: RuntimeError: Python is not installed as a framework
- Python 101: Can’t open file: No such file or directory
- TypeError: argument of type ‘NoneType’ is not iterable
- numpy-equivalent of list.pop?
- How to create a numpy array of lists?
- Python can’t find module NLTK
- convert csv file to list of dictionaries
- ImportError: cannot import name NUMPY_MKL
- Python: Pandas pd.read_excel giving ImportError: Install xlrd >= 0.9.0 for Excel support
- How can I copy a Python string?
- Element-wise addition of 2 lists?
- How do I add two sets?
- Convert string to variable name in python
- How to split elements of a list?
- Find object in list that has attribute equal to some value (that meets any condition)
- set object is not JSON serializable
- dump() missing 1 required positional argument: ‘fp’ in python json
- Iterating through list of list in Python
- Python cant convert ‘list’ object to str error [closed]
- Installing scipy for python 2.7
- How can I install a .egg Python package on Windows (attempt using easy_install not working)
- Determine if 2 lists have the same elements, regardless of order? [duplicate]
- Building a list inside a list in python
- Cannot remove entries from nonexistent file
- List all categories in options
- How do I create an alphabetically organized glossary of links?
- adding a #hash to each link in list_pages()?
- get_all_category_ids for bookmark
- List child pages alphabetically