[Python-Dev] For review: PEP 285: Adding a bool type

Neal Norwitz neal@metaslash.com
Fri, 08 Mar 2002 15:36:58 -0500


Skip Montanaro wrote:
> 
>     Hans> This may be a minor issue, but this proposal will break code like
> 
>     Hans>   days_feb = 28 + isleapyear(year)
> 
>     Hans> assuming that booleans cannot be added to ints. :-)
> 
> I don't think this will be a problem.  Guido's proposal is for bool to be a
> subclass of int.  Consequently, 28 + True should yield 29 (perhaps with a
> warning from PyChecker).

This gave me an idea that in general it might be useful to try to address
the ways that adding a new feature might break existing code.  Or
other problems which may occur.

I (or some other brave soul) could then use each case to add warnings
to pychecker.  This could help people prior to upgrading, 
which was a complaint I just read about on c.l.py.

If the cases were in the PEP, the portability concerns could be addressed
by pychecker.

To start the ball rolling on this PEP, here are the issues I can think of:

	* User already defining true or false in various cases
	* Performing any binary operation (+, -, *, /, **, &, |, ^) 
		on one or two booleans
	* return [01] -> false, true   # thanks, samuele

Neal