<br><div class="gmail_quote">On Sat, Feb 12, 2011 at 11:20 AM, Glen Jarvis <span dir="ltr">&lt;<a href="mailto:glen@glenjarvis.com">glen@glenjarvis.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Oh, and I&#39;m constrained to Python 2.5 or lower only :(<div><br></div><font color="#888888"><div>Glen</div></font><div><div></div><div class="h5"><div><br><div class="gmail_quote">On Sat, Feb 12, 2011 at 11:19 AM, Glen Jarvis <span dir="ltr">&lt;<a href="mailto:glen@glenjarvis.com" target="_blank">glen@glenjarvis.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">I remember, about three years ago, reading someone&#39;s answer to a question very similar to this. But, I can&#39;t find it now.<div>

<br></div><div>I have a raw input file where the first &quot;entity&quot; is a 64-bit unsigned integer and the remaining items in the file are 32-bit unsigned integers (until the end of the file).</div>
<div><br></div><div>I vaguely remember there was already a module to cleanly handle this. I could, of course, open the file (f) in binary mode and do an f.read() on each byte and figure thing out. But, one will have to think of byte swapping, variable &quot;sizes&quot;, etc. when running on different systems.</div>


<div><br></div><div>I thought there was a layer above this that would take care of the mapping of data in the file (i.e., a raw dump/raw read) to a set of variables, taking care of byte swapping if needed, size of types, etc. as long as I specified the format (i.e., first should be 64-bit unsigned, second... etc.)</div>


<div><br></div><div>Am I mistaking that this exists (i.e., did I just make this up)?</div><div><br></div><div>Cheers,</div><div><br></div><br></blockquote></div></div></div></div></blockquote><div> </div><div>You probably are thinking of struct  - perfect for byte level unpacking of records.<br>

<br>
<a href="http://www.doughellmann.com/PyMOTW/struct/">http://www.doughellmann.com/PyMOTW/struct/</a><br> 
<br></div></div>