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

Tim Peters tim.one@comcast.net
Sat, 09 Mar 2002 01:11:28 -0500


[David Abrahams]
> In general, I can change my doctests to use assert rather than looking
> for 1 or 0.

If you want x-version doctests, you could change

"""
>>> boolean_expect_true
1
>>> boolean_expect_false
0
"""

to, e.g.,

"""
>>> boolean_expect_true and 1
1
>>> boolean_expect_false or 0
0
"""

Then you won't get hosed by -O (as an assert would do).  You may not run
doctests with -O today, but the more -O does over time the more important it
will become to do so.

Right now running tests under -O mainly protects against logic errors
introduced by hiding crucial parts of the code in "if __debug__:" blocks,
and few people use __debug__ explicitly now.