[Python-ideas] IntFlags

random832 at fastmail.us random832 at fastmail.us
Mon Mar 9 16:01:12 CET 2015


On Mon, Mar 9, 2015, at 10:00, Neil Girdhar wrote:
> People have been discussing bool since it was introduced.  Many people
> have
> proposed that bool should not subclass int exactly for this reason (the
> Liskov substitution principle), but unfortunately bool evolved from int
> in
> Python 2.2.1 (I think?) when there was already a lot of code using int to
> implement Boolean variables with constants like False, True = 0, 1.  In
> order not to break too much code, it was decided to allow bool to inherit
> from int.  The inheritance of bool from int is not a good precedent when
> making inheritance decisions in the future.

And we're already using int in all these places people are talking about
dropping this new IntFlags class into. The situations seem exactly
analogous to me.


More information about the Python-ideas mailing list