[Tutor] What is the augmented assignment operator "^="

Dick Moores rdm at rcblue.com
Mon Feb 19 12:40:20 CET 2007


At 03:32 AM 2/19/2007, you wrote:
>Dick Moores wrote:
>>The docs list it at <http://docs.python.org/ref/augassign.html>, 
>>and send you to 
>><http://docs.python.org/ref/primaries.html#primaries>, which seems a dead end.
>
>a += n is more-or-less a shortcut for a = a + n. There are a few 
>subtleties which the first page you reference talks about, but you 
>can generally think of it as a handy abbreviation.
>
>For other operations, the same is true:
>a <op>= n is the same as a = a <op> n
>
>>I've tried "^=" out a bit and get that strange alternating behavior.
>
>which is normal operation of ^. Try it with + or * for a simpler example.

Of those listed on <http://docs.python.org/ref/augassign.html>,  I 
already use and understand "+=" | "-=" | "*=" | "/=" | "%=" | "**=" . 
It's the remaining seven I'm wondering about, or really about >>, <<, 
&, ^, and | . Andre's given me a good start, as you may have seen by now.

Dick




More information about the Tutor mailing list