PEP 285: Adding a bool type

gbreed at cix.compulink.co.uk gbreed at cix.compulink.co.uk
Wed Apr 3 09:06:07 EST 2002


Alex Martelli wrote:

> They'd come in handy for those peculiar situations where you HAVE
> to distinguish between integers and booleans, basically only when you 
> are
> interfacing some external subsystem such as a DB or RPC system that
> does require such distinctions (as opposed to ones that _don't_ support
> it, such as, we're told, MySql).  And, by not affecting built-ins, 
> operators, etc, they wouldn't be in the way in everyday life, nor, most
> particularly, would they impose conceptual burdens on teaching Python.

If I were interfacing with an RPC system that happened to use dynamic 
typing between languages with different boolean implementations, it'd be 
pretty darned convenient if 1+1==2 happened to convert magically to the 
system's boolean type.  That'd also be the first time the proposal would 
make any difference to me.  My everyday life isn't really affected by the 
type of 1+1==2, so long as it evaluates true in situations where that's 
relevant.

> Far more "not-pure", since the PEP requires _implicit_ conversion (or
> else tons of code would break).

AIUI the PEP makes booleans a subclass of integers.  Which means they 
already are integers so no conversion needs to take place for them to 
behave as integers.

> It would be quite possible to distinguish between int and Booleans if
> you needed to, even if Booleans came from a specific module rather
> than from builtins, of course.  Such a need is a very rare issue, thus
> it should not be allowed to get in the way for everyday usage.

Again, is there a suggestion that the PEP *would* get in the way of 
everyday usage?  For that first time you do need to distinguish, it'd save 
a lot of trouble going through the documentation if a comparison like x<10 
already worked.


                      Graham

          <http://www.microtonal.co.uk>



More information about the Python-list mailing list