type 'set''s difference between __str__ and printing directly
<pre><code>In [1]: import sys

In [2]: sys.version_info
Out[2]: sys.version_info(major=3, minor=5, micro=2, releaselevel='final', serial=0)

In [3]: b=set([10,20,40,32,67,40,20,89,300,400,15])

In [4]: b
Out[4]: {10, 11, 15, 20, 32, 40, 67, 89, 111, 300, 400}
</code></pre>



<pre><code>In [1]: import sys

In [2]: sys.version_info
Out[2]: sys.version_info(major=2, minor=7, micro=12, releaselevel='final', serial=0)

In [3]: b=set([10,20,40,32,67,40,20,89,300,400,15])

In [4]: b
Out[4]: set([32, 67, 40, 10, 11, 300, 15, 400, 20, 89, 111])
</code></pre>

<p>why have this different between 2 and 3?</p>

<p>Because the <code>{...}</code> syntax <a href="https://docs.python.org/2/whatsnew/2.7.html#python-3-1-features" rel="nofollow">wasn't introduced until Python 2.7</a>, and by that time the <code>set([...])</code> <code>repr()</code> format was already established.</p>

<p>So to keep existing Python 2 code that may have relied on the <code>set([...])</code> representation working, the <code>repr()</code> wasn't changed in the 2.x series. Python 3 had <code>{...}</code> notation for sets from the start.</p>

python python-3.x set python-2.x