Bitwise Operations

Terry Reedy tjreedy at udel.edu
Tue Jul 30 01:46:58 EDT 2013


On 7/29/2013 7:44 PM, Chris Angelico wrote:

> But there's an easier way:
>
>>>> x = 0b101 & 0b010
>>>> x
> 0
>
> I think that might do what you want. Also check out the bin()
> function, which will turn an integer into a string of digits.

 >>> bin(0b101 | 0b010)
'0b111'

Now you are set to go. Have fun.
-- 
Terry Jan Reedy




More information about the Python-list mailing list