pack heterogeneous data types

Diez B. Roggisch deets at web.de
Thu Jun 9 08:23:37 EDT 2005


ashokbellur at gmail.com wrote:
> Hello,
> 
> How do i pack different data types into a struct or an array. Examples
> would be helpful.
> 
> Say i need to pack an unsigned char( 0xFF) and an long( 0xAAAAAAAA)
> into a single array? The reason i need to do this is send a packet over
> a network.

You've been reposting this on a frequent base all the time for 2 weeks 
now - and everytime you've been told (by me and others) to use the 
module struct. So - how about actually trying so and come back if you 
hit the wall with that for whatever reason instead of unsuccsessfully 
shoehorning arrays int something you think they're supposed to be? 
Which, BTW, they aren't in _any_ language, as the are homogenous by 
nature and only pointer-tricks in C can get you around that.

Diez



More information about the Python-list mailing list