On 1/29/07, Kent Johnson <[EMAIL PROTECTED]> wrote: > Because 2 ^ 3 == 1, right? Are you sure you understand what xor does? It > is a bitwise exclusive or:
Yes... at a binary level, it returns true if either input is true, but not both: A B Q 0 0 0 0 1 1 1 0 1 1 1 0 Thus it has the effect of swapping / reversing. For some reason I had not been thinking straight, and had thought we might just see a toggle of the value of the variable, which is, of course, nonsense. So in my example: 2 = 00000010 3 = 00000011 xor: Q = 00000001 Lesson: think first... was just me being blind. > x, y = y, x Doesn't this use temporary variables? > Kent S. _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor