Compound Assignment Operators ( +=, *=, etc...)

Fred L. Drake, Jr. fdrake at
Fri Aug 20 11:08:00 EDT 1999

In comp.lang.python, 
    Timothy R Evans <tre17 at> writes:
 >def wibble():
 >    print x
 >    x = 6 # this fails with NameError
 >Seems like a good behaviour as it stops you doing dumb things.

Tom Christiansen writes:
 > Perhaps it could give a better error message, pretty please?  Sometimes
 > driving Python feels  like driving Ken Thompson's car.  It just keeps saying
 > "?" and you're expected to know what that means.  :-(

  Current behavior (1.5.2 as released) raises UnboundLocalError (a
subclass of NameError), which is much more informative and is usually
exactly what is needed to point out to the programmer where the coding 
error is.


Fred L. Drake, Jr.	     <fdrake at>
Corporation for National Research Initiatives

More information about the Python-list mailing list