how many bytes in an int

Reid Nichol rnichol_rrc at yahoo.com
Mon Aug 9 01:04:04 EDT 2004


Grant Edwards wrote:
> On 2004-08-09, Reid Nichol <rnichol_rrc at yahoo.com> wrote:
> 
> 
>>   I was wondering if I could control how many bytes are in an int and 
>>the byte order.  In C/C++ I can use int32 but how do I do this in 
>>python?  How can I control byte order?
> 
> 
> I suspect you want to use the "struct" module -- but it's a
> guess, since you haven't really said what it is you're trying
> to accomplish.
> 

I'm thinking of writing a movie file encoder (probably avi).  So, I need 
to output DWORD (lookup revealed its a 4-byte int) to a binary file. 
Therefore I need to know whether this can be done in python or not, 
which will tell me whether I'll try to do it or not.

But, since the 64-bit archecture is out, short, long, etc may change 
there meanings quite soon.  From what I've read in the struct module 
docs I can only tell it that it's a short, long, etc. but not whether 
it's exactly a 4-byte int.  Is there a way to do this?



More information about the Python-list mailing list