On 2010-06-17, Stephen Hansen <me+list/pyt...@ixokai.io> wrote: >>>> BIT_1 = 1 << 0 >>>> BIT_2 = 1 << 1
... > Basically, those BIT_X lines are creating numbers which have *only* the > specified bit set. Then you do "byte & BIT_X", and that will return 0 if > the byte doesn't have the specified bit in it. You can then set the bit > with "byte | BIT_X", and unset the bit with "byte ^ BIT_X". Just to clarify, "byte ^ BIT_X" inverts (toggles) bit X. If you want to make sure bit X is a 0 (which is what people usually mean by "unset"), you do "byte & ~BIT_X" -- Grant Edwards grant.b.edwards Yow! I know things about at TROY DONAHUE that can't gmail.com even be PRINTED!! -- http://mail.python.org/mailman/listinfo/python-list