Pythonic bit twiddling

Jim Richardson warlock at eskimo.com
Thu Feb 21 20:59:14 EST 2002


Pythonic bit shuffling question

I have an application that does a calculation on a single byte of data,
after breaking it into an upper and lower nibble of four bits. How can I
do this in python? To clarify.
Take a single byte, break off the upper 4 bits, and do some stuff, then
do similar stuff with the lower nibble, and then munge them back
together to create a byte again. This is for a checksum to inteface with
a bit of embedded stuff. I know how I can do this in C, but as that
would be the sole bit of copiled code in the app, I'd prefer to avoid
it if possible. 


Thanks all

-- 
Jim Richardson
	Anarchist, pagan and proud of it
www.eskimo.com/~warlock
    "New MS-Wheel, now with 8 sides for a smoother ride!"



More information about the Python-list mailing list