flipping bits in python,n ^= (1 << upper) - 1 & ~((1 << lower) - 1)