PEP 285: Adding a bool type

Chris Barker Chris.Barker at noaa.gov
Tue Apr 2 14:17:57 EST 2002


WOW! fabulous post, Laura. As a result of mainly this post, I have
changed my thinking somewhat.

Laura Creighton wrote:

> Python does not distinguish between True and
> False -- Python makes the distinction between something and nothing.

> So I out-and-out tell people this.  {} is a dictionary-shaped nothing.
> [] is a list-shaped nothing. 0 is an integer-shaped nothing.
> 0.0 is a float shaped nothing.

Thinking in terms of something vs. nothing is an excellent way to
explain how Python treats these things, but I still have a problem with
it. Who is to say that an empty list is nothing? or 0 for that matter. 0
particularly: it is an integer, and a very useful one at that, I find it
very inconvenient that 0 is always interpreted as nothing (see the
string.find() example). In Python the only object I want consistently
interpreted as nothing is None.

That being said, the proposed "int-in-a-hat" (nice coinage, Laura), does
not solve my problem at all. Everything that is currently interpreted as
nothing will continue to be so interpreted, which is must be so as not
to break probably every module over ten or so lines of code long.

The Python language is very much set in its ways: it relies on the
concept of something vs. nothing, and it has pre-defined what nothing is
for all the standard types in a very useful way. I'd be happier if that
legacy didn't exist, but like many people posting, I feel this halfway
measure is worse than what we have now.

Perhaps for Py3k, if we accept code breakage galor, a real Bool can be
introduced, and we can get rid of de-facto definitions of particular
values of an object being nothing. For now, let's keep it the way it is.

-Chris

-- 
Christopher Barker, Ph.D.
Oceanographer
                                    		
NOAA/OR&R/HAZMAT         (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov



More information about the Python-list mailing list