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

Tom Christiansen tchrist at
Thu Aug 19 22:44:43 EDT 1999

     [courtesy cc of this posting mailed to cited author]

In comp.lang.python, 
    Timothy R Evans <tre17 at> writes:
:x = 5
:def foo():
:    print x # works, prints 5
:def bar():
:    x = 6 # works, but doesn't change the global
:def wibble():
:    print x
:    x = 6 # this fails with NameError
:Seems like a good behaviour as it stops you doing dumb things.

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.  :-(


PS: From an old joke about Ken's treatment of error messages in ed.
    If I allowed "next $label" then I'd also have to allow "goto $label",
    and I don't think you really want that...  :-) [now works in perl5!]
            --Larry Wall in <1991Mar11.230002.27271 at>

More information about the Python-list mailing list