"Stef Mientki" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
| John Machin wrote:
| So now I'm left with just one question:
| for bitwise operations I should use &, |, ^
| for boolean operations I should use and, or, xor
| but after doing some test I find strange effects:
| >>> A = 4
| >>> B = 5
| >>> A and B
| 5

>>> B and A
4

| >>> A & B
| 4
| >>> A or B
| 4

>>> B or A
5

| >>> A | B
| 5
|
| So if I use the bitwise operation on integers,
|   "and" changes into (bitwise) "or" and vise versa.

No, you hypnotised yourself by generalizing from insufficient data.
Repeat experiment with, for instance, 3 and 4 instead of 4 and 5.  Then 3&4 
= 0, 3|4 = 7.

tjr



-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to