what does ^ do in python

Guilherme Polo ggpolo at gmail.com
Tue Mar 25 18:13:00 EDT 2008


2008/3/25, Dark Wind <darkwind.87 at gmail.com>:
> Hi,
>
> In most of the languages ^ is used for 'to the power of'. In python we have
> ** for that. But what does ^ do?

It is bitwise xor. Some more information can be found at
http://docs.python.org/ref/bitwise.html

> I could not get it just by using it ... some examples are:
> 1^1 returns 0
> 2^2 returns 0
>  1^4 returns 5
> 4^1 returns 5
> 3^5 returns 6
> 5^3 returns 6 ......
>
> just curious
>
> Thank you
>
> --
>  http://mail.python.org/mailman/listinfo/python-list
>


-- 
-- Guilherme H. Polo Goncalves



More information about the Python-list mailing list