Retrieving an object from a set

Vito De Tullio vito.detullio at gmail.com
Sat Jan 26 02:55:50 EST 2013


MRAB wrote:

> It turns out that both S & {x} and {x} & S return {x}, not {y}.

curious.

$ python
Python 2.7.3 (default, Jul  3 2012, 19:58:39) 
[GCC 4.7.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> x = (1,2,3)
>>> y = (1,2,3)
>>> s = set([y])
>>> (s & set([x])).pop() is y
False
>>> (set([x]) & s).pop() is y
True

maybe it's implementation-defined?

-- 
ZeD




More information about the Python-list mailing list