Shift Confusion

Lars lars-www at lycos.com
Fri Feb 25 05:42:16 EST 2005


Hi Kamilche,

Aside from the 7bit confusion you should take a look at the 'struct'
module. I bet it will simplify your life considerably.

#two chars
>>> import struct
>>> struct.pack('cc','A','B')
'AB'

#unsigned short + two chars
>>> struct.pack('Hcc',65535,'a','b')
'\xff\xffab'


Cheers
Lars




More information about the Python-list mailing list