I am running the following code in ipython and am surprised at the print outputs and the ipython cell outputs of the code:
print set(["A", "B", "C"])
print set(["A", "C", "B"])
print list(set(["A", "C", "B"]))
print list(set(["A", "B", "C"]))
print [k for k in set(["A", "C", "B"])]
print [k for k in set(["A", "B", "C"])]
a = set(["A", "B", "C"])
print a
print a.__repr__()
print a.__str__()
print [(k, hash(k)) for k in a]
a
The output of the above program is as follows:
set(['A', 'C', 'B'])
set(['A', 'C', 'B'])
['A', 'C', 'B']
['A', 'C', 'B']
['A', 'C', 'B']
['A', 'C', 'B']
set(['A', 'C', 'B'])
set(['A', 'C', 'B'])
set(['A', 'C', 'B'])
[('A', -269909568), ('C', -13908798), ('B', -141909181)]
Out[34]: {'A', 'B', 'C'}
Note, that the cell output is {'A', 'B', 'C'}
while the printed output is set(['A', 'C', 'B'])
My Python details are as follows:
import sys
print sys.version
2.7.11 |Anaconda 2.3.0 (64-bit)| (default, Jan 29 2016, 14:26:21) [MSC v.1500 64 bit (AMD64)]