Extending struct.unpack

Amritansh Raghav amritansh at mobilian.com
Tue Jan 30 21:56:19 EST 2001


I have a buffer of data which I want to unpack but one of the unpacked
fields is not an inbuilt specifier to struct.unpack(). I would like to
extend unpack so that it can take a new format specifier, call out to my
function when it encounters that format character, and then continue
unpacking after 'n' characters (the value 'n' being returned by the function
that is called out to).
Is there any way of accomplishing this?
Thanks

p.s (for more info - the buffer i want to unpack contains an ethernet
address which is 6 bytes. currently i unpack it using 6B, but i would like
to specify it as say E and have unpack return a 6byte long number)





More information about the Python-list mailing list