Manipulating specific bits

Stephen Hansen stephen at cerebralmaelstrom.com
Thu Jun 22 05:58:57 EDT 2000


    Okay, this is a Very Newbie-ish question.

    What I need to do is manipulate specific bits in a byte, for
transmission. I have absolutely *no* idea how to do this. :)
    For example, say I have my 1 byte: 0 0 0 0 0 0 0 0. Say I want to set
the 2nd and 5th bit to 1.. how the heck do I do that? :)
    I've never actually even /blinked/ in the direction of bit-ish
manipulation, so am utterly clueless. Next i'm gonna have to stick it into a
struct I think, before transmission.. I think. dunno. Will look into that
afterwards.

Thanks. :)

--S





More information about the Python-list mailing list