[Python-Dev] Re: PEP 285: Adding a bool type
Andrew Koenig
ark@research.att.com
03 Apr 2002 12:36:14 -0500
>> I mean that the language doesn't prefer a single way,
>> as opposed to programmers' conventions.
Fredrik> it's more than just a convention -- built-in functions and
Fredrik> operators always return 0 for false and 1 for true whenever
Fredrik> they need to invent a boolean value. this is documented in
Fredrik> the language reference.
On the other hand, the library isn't nearly so consistent. Just for
fun, I started browsing the library documentation at random.
The very first page I visited was the description of gc, the
garbage collector interface. The first function that returns
a truth value there is described as
isenabled()
Returns true if automatic collection is enabled.
Some more examples:
2.2.6.1 String Methods
endswith(suffix[,start[,end]])
Return true if the string ends with the specified suffix,
otherwise return false.
Similarly for isalnum, isalpha, isdigit, islower, isspace.
2.2.8 File Objects:
isatty()
Return true if the file is connected to a tty(-like) device,
else false.
6.2 os.path -- Common pathname manipulations
exists(path)
Return true if path refers to an existing path.
I'm sure there are others.
--
Andrew Koenig, ark@research.att.com, http://www.research.att.com/info/ark