set() and frozenset() functions generate mutable and immutable sets, respectively. : Set : Collections PYTHON TUTORIALS


PYTHON TUTORIALS » Collections » Set »

 

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('%dn' % i)
    
f.close()
f = open('numbers', 'r')
print set(f)
f.close()



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON TUTORIALS

 Navioo Collections
» Set