Re: Retrieving an object from a set

Discussion in 'Python' started by Vito De Tullio, Jan 26, 2013.

  1. 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
    Vito De Tullio, Jan 26, 2013
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Arnaud Delobelle

    Retrieving an object from a set

    Arnaud Delobelle, Jan 25, 2013, in forum: Python
    Replies:
    1
    Views:
    110
    Steven D'Aprano
    Jan 26, 2013
  2. Ian Kelly

    Re: Retrieving an object from a set

    Ian Kelly, Jan 25, 2013, in forum: Python
    Replies:
    0
    Views:
    107
    Ian Kelly
    Jan 25, 2013
  3. Ian Kelly

    Re: Retrieving an object from a set

    Ian Kelly, Jan 25, 2013, in forum: Python
    Replies:
    0
    Views:
    99
    Ian Kelly
    Jan 25, 2013
  4. MRAB
    Replies:
    0
    Views:
    108
  5. Ethan Furman

    Re: Retrieving an object from a set

    Ethan Furman, Jan 25, 2013, in forum: Python
    Replies:
    0
    Views:
    108
    Ethan Furman
    Jan 25, 2013
Loading...

Share This Page