the otherregardless of order for instanceyou might use this to compare the outputs of programs that should work the same but may generate results in different order sorting before testing has the same effect for equalitybut sets don' rely on an expensive sortand sorts order their results to support additional magnitude tests that sets do not (greaterlessand so on) [ ][ = order matters in sequences false set( =set( order-neutral equality true sorted( =sorted( similar but results ordered true 'spam='asmp'set('spam'=set('asmp')sorted('spam'=sorted('asmp'(falsetruetruesets can also be used to keep track of where you've already been when traversing graph or other cyclic structure for examplethe transitive module reloader and inheritance tree lister examples we'll study in and respectivelymust keep track of items visited to avoid loopsas discusses in the abstract using list in this context is inefficient because searches require linear scans although recording states visited as keys in dictionary is efficientsets offer an alternative that' essentially equivalent (and may be more or less intuitivedepending on whom you askfinallysets are also convenient when you're dealing with large data sets (database query resultsfor example)--the intersection of two sets contains objects common to both categoriesand the union contains all items in either set to illustratehere' somewhat more realistic example of set operations at workapplied to lists of people in hypothetical companyusing / set literals and result displays (use set in and earlier)engineers {'bob''sue''ann''vic'managers {'tom''sue''bobin engineers true is bob an engineerengineers managers {'sue'who is both engineer and managerengineers managers {'bob''tom''sue''vic''ann'all people in either category engineers managers {'vic''ann''bob'engineers who are not managers managers engineers {'tom'managers who are not engineers engineers managers false are all managers engineers(superset numeric types