(data,value,offset,bits=1)
return data
Set specified bits in integer

        >>> bin(set_bits(0,0b1010,0,4))
        '0b1010'
        >>> bin(set_bits(0,0b1010,3,4))
        '0b1010000'
Set specified bits in integer
Set specified bits in integer
def set_bits(data,value,offset,bits=1):
    """
        Set specified bits in integer

        >>> bin(set_bits(0,0b1010,0,4))
        '0b1010'
        >>> bin(set_bits(0,0b1010,3,4))
        '0b1010000'
    """
    mask = ((1 << bits) - 1) << offset
    clear = 0xffff ^ mask
    data = (data & clear) | ((value << offset) & mask)
    return data
def set_bits ( data , value , offset , bits = 1 ) : mask = ( ( 1 << bits ) - 1 ) << offset clear = 0xffff ^ mask data = ( data & clear ) | ( ( value << offset ) & mask ) return data