21 Dec
2020
21 Dec
'20
7:59 a.m.
I know this has come up in the past. Could the consensus have changed regarding bool's inheritance from int? This is not intuitive (to me), and recently bit me as a bug: Python 3.9.1 (default, Dec 13 2020, 11:55:53) [GCC 10.2.0] on linux Type "help", "copyright", "credits" or "license" for more information.
{1,True} {1}
I've worked around it by storing tuple(type, value) in the set, which is fugly. Yes, I need mixed types in the set, and I'm using the set for efficient lookup. A contrived example I dreamed-up, which I also find non-intuitive:
x = {} x[True] = 1 x {True: 1} x[1] = 1 x {True: 1}
Maybe a wish list item for Python 4.0?