On Feb 2, 2005, at 10:19, Ewald Ertl wrote:

Hi!

Using binary operations:

a='0x87BE'
str(hex(int(a,16) & 0xFF))
'0xbe'
str(hex((int(a,16) & 0xFF00) / 0xFF))
'0x87'


HTH Ewald

Actually, the int conversions aren't even necessary.

>>> hex(0x87BE & 0xFF)
'0xbe'
>>> hex((0x87BE & 0xFF00) / 0xFF)
'0x87'


-- Max
maxnoel_fr at yahoo dot fr -- ICQ #85274019
"Look at you hacker... A pathetic creature of meat and bone, panting and sweating as you run through my corridors... How can you challenge a perfect, immortal machine?"


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to