Mega Code Archive

 
Categories / Python Tutorial / Collections
 

Set() and frozenset() functions generate mutable and immutable sets, respectively

print set() print set([]) print set(()) print set('BC') print frozenset(['foo', 'bar']) f = open('numbers', 'w') for i in range(5):     f.write('%d\n' % i)      f.close() f = open('numbers', 'r') print set(f) f.close()