Re:What's New in Python 3.11?
by duckerude on Monday June 27, 2022 @05:23AM
(#31892276)
That problem also exists in sets because some values that aren't interchangeable still compare equal:
But the behavior for dicts is surprising even in that light:
[ Parent
| on HN ]
Re:What's New in Python 3.11?
by wodenokoto on Tuesday June 28, 2022 @08:13AM
(#31906685)
But that is not really the `|` operators fault. You get the exact same behaviour when you create a dictionary.
>>> {1: 1, 1.0: 1.0, True: True}
{1: True}
So `|` between dictionaries behaves just as you'd expect, if your expectations about creating a dictionary are correct. I think that's very reasonable.