Struggling with struct.unpack() and "p" format specifier

Peter Hansen peter at engcorp.com
Tue Nov 30 10:43:24 EST 2004


Peter Hansen wrote:
> I would be inclined to say that the "p" format in struct (using
> Python 2.4rc1 or Python 2.3.3) does not act as documented on
> Windows XP SP2, at least...
> 
> I hope we've both just missed something obvious.

Okay, we were certainly missing something, but I don't believe
I would call it obvious.

I can't deduce from the documentation the fact that the "p"
format requires a length *in front of the p in the format string*.

Furthermore, it assumes a length of 1 if one is not specified.

And there is no example that shows how to do it correctly.

(I did Google searches and found examples, but by then I
was looking for a bug report and didn't even think to look
at the examples themselves. :-(  )

Doc bug?  Did anyone else find the documentation on "p"
to be clear and effective?

-Peter



More information about the Python-list mailing list