![]() | the sleepy snakeindex :: num :: BitArray | |||||||||||||||||||||||||||||||||||
class BitArray?wrapper class for bit handling . The class handles up to 32 bits, bits exceeding this limit are ignored The BitArray class defines the following attributes:
The BitArray class defines the following methods:
sample code arr = BitArray() arr[3] = 1 # set third bit >> '100' arr[1] = 2 # toggle 2nd bit >> '101' arr[:] = 1 # set all bits >> '11111111111111111111111111111111' arr.clear() # clear all bits >> '0' MY_FLAG_1 = 0 MY_FLAG_32 = 31 arr = BitArray() arr[MY_FLAG_1] = 1 print arr[MY_FLAG_1] >> 1 | ||||||||||||||||||||||||||||||||||||