Silly questions about True and False

drs drs at remove-to-send-mail-ecpsoftware.com
Mon Dec 20 13:12:27 EST 2004


I just upgraded my Python install, and for the first time have True and
False rather than 1 and 0.  I was playing around at the command line to test
how they work (for instance, "if 9:" and "if True:" both lead to the
conditional being executed, but True == 9 -> False, that this would be true
was not obvious to me -- "True is True" is True, while "9 is True" is false
even though 9 evaluates to True.)  Anyhow, in doing my tests, I accidentally
typed

>>> False = 0

rather than

>>> False == 0

and I lost the False statement.
Thus,

>>> False
0

To get it back, I found that I could do

>>> False = (1 == 2)

which seems to put False back to False, but this seems weird.

>>> 1 = 0

throws an error (can't assign to literal), why doesn't False = 0 throw the
same error?  Also, why doesn't False = 0 make

>>> 1 == 2
0

Instead of False?

-d





More information about the Python-list mailing list