[Python-Dev] For review: PEP 285: Adding a bool type (original) (raw)

David Abrahams David Abrahams" <david.abrahams@rcn.com
Sat, 9 Mar 2002 07:43:38 -0500


----- Original Message ----- From: "Tim Peters" <tim.one@comcast.net>

[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 """ >>> booleanexpecttrue 1 >>> booleanexpectfalse 0 """ to, e.g., """ >>> booleanexpecttrue and 1 1 >>> booleanexpectfalse or 0 0 """ Then you won't get hosed by -O (as an assert would do).

...I guess I can see why you're really intending that

>>> 0 or False
False

but

>>> False or 0
0

This sure rubs all my expectations for a bool the wrong way, though. I think I'd better just write my own assertion routine, as Guido suggested. I don't like non-obvious language constructs for something so simple (I'd mention ?: here but I don't need the bruises).

You may not run doctests with -O today, but the more -O does over time the more important it will become to do so.

Yes.