On 09/12/05, Tim Johnson <[EMAIL PROTECTED]> wrote: > Are there any python resources available that can make setting/unsetting > bits directly? I used to do that in "C" with preprocessor macros that > made calls like set_bit(vInteger,bit_position) > and unset_bit(vInteger,bit_position).
Well, you could write them yourself? [untested] def set_bit(i, n): return i | (1 << n) def unset_bit(i, n): return i & ~(1 << n) def test_bit(i, n): return i & (1 << n) Note that integers are immutable, so there's no way to change an existing int. Also, if you're playing with stuff at that level, you might find the struct module helpful. -- John. _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor