# Regular sets are mutable, hence cannot be used as dictionary keys or elements of other sets. # my_dict = { {'a', 'b'}: 'value' } # This would raise a TypeError: unhashable type: 'set' # frozenset is an immutable version of set tags_for_article_1 = frozenset({'python', 'webdev', 'backend'}) tags_for_article_2 = frozenset({'python', 'frontend', 'javascript'}) tags_for_article_3 = frozenset({'go', 'backend'}) # frozensets are hashable, so they can be used as dictionary keys article_counts_by_tags = { tags_for_article_1: 5, tags_for_article_2: 3, tags_for_article_3: 8 } print(f"Article 1 count: {article_counts_by_tags[frozenset({'python', 'webdev', 'backend'})]}") # You can also perform set operations on frozensets common_tags = tags_for_article_1.intersection(tags_for_article_2) print(f"Common tags between article 1 and 2: {common_tags}") # Example: Grouping data by unique combinations of permissions user_permissions = { 'admin': frozenset({'read', 'write', 'delete'}), 'editor': frozenset({'read', 'write'}), 'viewer': frozenset({'read'}) } print(f"Admin permissions: {user_permissions['admin']}")