[Python-Dev] Re: PEP 285: Adding a bool type
Fredrik Lundh
fredrik@pythonware.com
Wed, 3 Apr 2002 20:18:50 +0200
Andrew Koenig wrote:
> 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.
>>> import gc
>>> gc.isenabled()
1
>>> type(gc.isenabled())
<type 'int'>
> endswith(suffix[,start[,end]])
> Return true if the string ends with the specified suffix,
> otherwise return false.
>>> "spam".endswith("m")
1
>>> type("spam".endswith("m"))
<type 'int'>
> isatty()
> Return true if the file is connected to a tty(-like) device,
> else false.
>>> sys.stdout.isatty()
1
>>> type(sys.stdout.isatty())
<type 'int'>
> exists(path)
> Return true if path refers to an existing path.
>>> os.path.exists("/etc/passwd")
1
>>> type(os.path.exists("/etc/passwd"))
<type 'int'>
looks pretty consistent to me ;-)
(Python docs tend to use "true" to mean anything which isn't "false", and
where operator.truth returns the right thing. this won't change post-PEP
-- if you start interpreting "return true" as "return True", you'll be asking
for trouble)
</F>