[Python-Dev] Boolean transition
Martin v. Loewis
martin@v.loewis.de
09 Mar 2002 23:34:59 +0100
Paul Prescod <paul@prescod.net> writes:
> I'm in favour of adding the boolean feature in as compatible a manner as
> possible. But I think that we need a transition plan to separate
> booleans from integers. Booleans are not integers and
> True+True-False+5=6 is just weird. Arithmetic manipulation of booleans
> should be deprecated and should fade away. isinstance(True, int) should
> be deprecated. etc.
I don't find that too wierd; certainly not more puzzling than {} < ().
If arithmetic operations on booleans are to be deprecated, I'd suggest
the following strategy:
- add booleans to 2.3 (or perhaps 2.4?)
- deprecate arithmetic operations on them in 2.4, by means of a warning
This will tell how frequent that warning is, so it may need to be
disabled in 2.4.1. If it is going to stay
- let arithmethic operations on booleans raise TypeErrors in 2.5
- stop inheriting from int in 2.6.
> The current subtyping strategy provides a better hook for deprecation
> warnings. My only concern is that we decide and document that booleans
> will one day be as completely unrelated to integers as exceptions are to
> strings.
I'm not sure that this is desirable. By the same rationale, you should
argue that boolean operations on integers are a bad thing. This would
be not Pythonic.
Regards,
Martin