Python: How to Construct a Bit Mask?