News for hackers. Stuff that matters.
Re:Python 3.9 by quietbritishjim on Tuesday October 06, 2020 @02:59AM (#24695328)
[Edit: I thought the parent comment was saying that they were expecting dict1 | dict2 to equal either dict1 or dict2, not some combination of them. Instead, they were referring to the which value gets chosen if the same key is in both dictionaries. Thanks to minitech for their comment that helped me see what they were saying.]

Are you also surprised when the original bitwise meaning of "|" does not return either of the two arguments?

    >>> 5 | 3
    7
Here's the same thing as binary:

    >>> bin(0b101 | 0b011)
    '0b111'
Re:Python 3.9 by DougBTX on Tuesday October 06, 2020 @04:05AM (#24695628)
Bitwise or works at the level of bits, so the question is more like, in:

    >>> bin(0b011 | 0b010)
    '0b11'
Does the leading 1 come from the first argument or the second argument? It isn't really a sensible question for bits, since the 1s are indistinguishable. However the values in the hash table are distinguishable, so it's a valid question.

Also, taking an example from another comment:

    >>> {0} | {False}
    {0}
    >>> {False} | {0}
    {False}
This is another example where the union operator is used, but here it picks the first value, rather than the second value.
Re:Python 3.9 by quietbritishjim on Tuesday October 06, 2020 @05:00AM (#24695903)
Ouch, that is pretty nasty.