Why this apparent assymetry in set operations?

Sergio Correia sergio.correia at gmail.com
Tue Jan 15 11:15:33 EST 2008


Both of you are correct.

>>> x = set([1,2,3])
>>> y = set([4,5])
>>> x |= y
>>> x
set([1, 2, 3, 4, 5])


On Jan 15, 2008 11:07 AM, Skip Montanaro <skip at pobox.com> wrote:
> > > Why is that?  Doesn't the |= operator essentially map to an update() call?
> >
> > No, according to 3.7 Set Types, s | t maps to s.union(t).
>
> I was asking about the |= assignment operator which according to the
> docs *does* map to the update method.
>
> Skip
>
>
>
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



More information about the Python-list mailing list