True/False

John Roth johnroth at ameritech.net
Wed Apr 23 07:14:51 EDT 2003


"Ian Bicking" <ianb at colorstudy.com> wrote in message
news:mailman.1051081416.21801.python-list at python.org...
On Wed, 2003-04-23 at 00:29, Martin v. Löwis wrote:
> 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+.

The other point in writing it this way is that it allows the compiler to
recognize
the idiom and remove it without issuing a warning. Whether or not
the compiler will ever do this is another issue, but I would consider
it a definite plus in providing a clean, hassle free migration path.

John Roth

Ian









More information about the Python-list mailing list