(no subject)

Erik Max Francis max at alcyone.com
Sat Feb 1 05:06:18 CET 2003

Chad Netzer wrote:

> Perhaps rather than do a version check, you could do:
> try:
>     True
>     False
> except NameError:
>     # Add to builtins here

I've been considering this for EmPy (where I use True and False for
clarity but which must be portable all the way back to 1.5.2). 
Especially in the case of a standalone program that may be invoked many
times (driven by make, for instance), I'm not sure the overhead of
catching the NameError every single time the script is invoked is worth
the extra value of 1. using the True/False builtins (equal to 1/0 in
2.2.x) or 2. actually having the True/False really be bools (2.3 and

So I just start with a

	False, True = 0, 1

at the top and move on from there.  (Since the script is backward
compatible, it never takes advantages of the True/False-as-real-Booleans
features anyway.)

 Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
 __ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/  \ It is much safer to obey than to rule.
\__/ Thomas a Kempis
    Sade Deluxe / http://www.sadedeluxe.com/
 The ultimate Sade encyclopedia.

More information about the Python-list mailing list