Assign to True / False in 2.3

Erik Max Francis max at
Wed Jul 2 12:02:59 CEST 2003

Culley Angus wrote:

> I was a little suprised to find that I could assign a value to 'True',
> and 'False' without warning though, and was wondering if this is
> deliberate.

This is true of pretty much all Python features.  The only special
dispensation goes to None, which is a warning now (in the 2.3 beta):

Python 2.3b2 (#1, Jun 29 2003, 20:30:58) 
[GCC egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> None = 0
<stdin>:1: SyntaxWarning: assignment to None

Python takes the approach of "We're all adults here."  If you're using
Python, it presumes that you don't need handholding, and that you won't
do things you know you shouldn't do.  For instance, imagine the havoc
that things like this would cause:

>>> int = float
>>> file = str   
>>> sys = 'This is really not a module'

   Erik Max Francis && max at &&
 __ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
/  \ Shooters, looters / Now I got a laptop computer
\__/  Ice Cube

More information about the Python-list mailing list