4 ms·
That problem also exists in sets because some values that aren't interchangeable still compare equal: >>> {1} | {1.0} | {True} {1} But the behavior for di
by duckerude 4y ago
That problem also exists in sets because some values that aren't interchangeable still compare equal:
>>> {1} | {1.0} | {True}
{1}
But the behavior for dicts is surprising even in that light:
>>> {1: 1} | {1.0: 1.0} | {True: True}
{1: True}
- kzrdude 4y agobool as int is sometimes useful and often infuriating
- wodenokoto 4y agoBut 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.