[Tutor] What is the augmented assignment operator "^="
kent37 at tds.net
Mon Feb 19 12:32:25 CET 2007
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.
More information about the Tutor