def get_bits(data, offset, bits=1):
 mask = (((1 << bits) - 1) << offset)
 return ((data & mask) >> offset)

def get_bits ( data , offset , bits = 1 ) : mask = ( ( ( 1 << bits ) - 1 ) << offset ) return ( ( data & mask ) >> offset )
get specified bits from integer .