Carlo Sogono wrote:
Ben Leslie wrote:
Also definately recommend the struct class.
I'm trying to use struct.pack to create a single byte with the value 01.
My two choices are probably x (pad byte) and c (char) but as expected
none of them worked:
>>> struct.pack('x', 1)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
struct.error: too many arguments for pack format
...because it doesn't want an argument and just defaults to 00 and...
>>> struct.pack('c', 1)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
struct.error: char format require string of length 1
... because 1 is an integer. How do I create a single byte with the
value 01 (not the ascii '1')?
Sorry for the noob questions. :)
Carlo
Oops disregard that. I didn't notice the signed/unsigned char types. :D
_______________________________________________
coders mailing list
coders@slug.org.au
http://lists.slug.org.au/listinfo/coders