> It deals with variable sized fields just fine:
> 
> dtype = 18
> dlength = 32
> format = "!BB%ds" % dlength
> 
> rawdata = struct.pack(format, (dtype,dlength,data))

I wouldn't call this "just fine", though - it involves
a % operator to even compute the format string. IMO,
it is *much* better not to use the struct module for this
kind of problem, and instead rely on regular string
concatenation.

Regards,
Martin
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to