Eww.. This isn't new in 3.9, but is mentioned in the dict section as an existing quirk of sets I didn't realize this:
>>> {0} | {False}
{0}
>>> {False} | {0}
{False} >>> {0} | {False}
{0}
>>> {False} | {0}
{False}Before bool existed, some folks had a habit of writing `False = 0` and `True = 1` for readability.
A nice side effect is that bools can used with sum:
sum(x % 10 for x in range(1000)) >>> {1} | {1.0}
{1}
>>> {1.0} | {1}
{1.0}
>>> import fractions
>>> x = fractions.Fraction(1)
>>> {x} | {1}
{Fraction(1, 1)}
>>> {1} | {x}
{1}For future internet historians, it should have been:
sum(x % 10 == 0 for x in range(1000))