This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Hamish Campbell
Recipients Hamish Campbell, docs@python
Date 2016-01-06.02:42:20
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
It looks like the behaviour of set displays do not match behaviour in some cases. The documentation states:

"A set display yields a new mutable set object, the contents being specified by either a sequence of expressions or a comprehension. When a comma-separated list of expressions is supplied, its elements are evaluated from left to right and added to the set object. When a comprehension is supplied, the set is constructed from the elements resulting from the comprehension."

Note the following:

   >>> foo = { True, 1 }
   >>> print(foo)

However, if we add elements 'left to right':

   >>> foo = set()
   >>> foo.add(True)
   >>> foo.add(1)
   >>> print(foo)

Note that similar documentation for dict displays produces the expected result.

"If a comma-separated sequence of key/datum pairs is given, they are evaluated from left to right to define the entries of the dictionary: each key object is used as a key into the dictionary to store the corresponding datum. This means that you can specify the same key multiple times in the key/datum list, and the final dictionary’s value for that key will be the last one given."

   >>> foo = {}
   >>> foo[True] = 'bar'
   >>> foo[1] = 'baz'
   >>> print(foo)
   {True: 'baz'}

Which matches the dict display construction:

   >>> foo = { True: 'bar', 1: 'baz'}
   >>> print(foo)
   {True: 'baz'}

Note that I've tagged this as a documentation bug, but it seems like the documentation might be the preferred implementation.
Date User Action Args
2016-01-06 02:42:21Hamish Campbellsetrecipients: + Hamish Campbell, docs@python
2016-01-06 02:42:21Hamish Campbellsetmessageid: <>
2016-01-06 02:42:21Hamish Campbelllinkissue26020 messages
2016-01-06 02:42:20Hamish Campbellcreate