True/False
Martin v. Löwis
martin at v.loewis.de
Wed Apr 23 01:29:16 EDT 2003
Erik Max Francis <max at alcyone.com> writes:
> but at this point it's looking awfully ugly.
That's why it will take a long time until Python warns about
assignments to True/False. Essentially, when Python 2.3 is considered
an old Python version (i.e. at Python 4.0), the warning may be
enabled. If the warning hasn't been seen for some time (say, at Python
6.2), it becomes an error.
So the typical process is that people will have to actively break
backwards compatibility at some time by removing the assignment.
There is still a point in writing
try:
True
except NameError:
True, False = 1, 0
as this gives you the "proper" boolean objects in 2.3+.
People which want to be absolutely forwards compatible have two
options:
a) use some other names for internal boolean constants, e.g.
try:
true, false = True, False
except NameError:
true, false = 1, 0
b) import True, False from a module that doesn't get installed
in Python 2.3+
try:
from boolcompat import *
except ImportError:
pass
boolcompat would be shipped only for 2.1 and earlier.
Regards,
Martin
More information about the Python-list
mailing list