[Python-ideas] IntFlags

Neil Girdhar mistersheik at gmail.com
Mon Mar 9 16:54:07 CET 2015


The differences are that the flags are used in a tiny portion of Python
code, and of that tiny amount of code, 99% of it probably uses nothing more
than the minimum "flags interface" that the composition solution has.  bool
was not like that.  Changing bool to be its own type would led to many more
problems.

On Mon, Mar 9, 2015 at 11:01 AM, <random832 at fastmail.us> wrote:

> 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.
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
> --
>
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "python-ideas" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/python-ideas/L5KfCEXFaII/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> python-ideas+unsubscribe at googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150309/c1d88e14/attachment.html>


More information about the Python-ideas mailing list