array problems.. OverflowError

Chris Lambacher lambacck at gmail.com
Wed Jun 8 13:49:51 EDT 2005


You probably want to look at using struct.pack.  That will allow you
to back heterogenious groups of data into a string that can be saved
to disk or sent over the network.  It also does a really good job of
taking care of byte order for you(if you tell it to).

-Chris

On 8 Jun 2005 10:40:43 -0700, ashtonn at gmail.com <doodle4 at gmail.com> wrote:
> How do i fill 1 byte and 4 bytes in a single array? This array contains
> packet information.
> 
> Python code...
> 
> from array import *
> 
> size = 526
> pData = array("B", '\0'* 526)
> # Destination MAC address
> destAddress = FFFFFFFFFFFF
> for i in range(0, len(destAddress), 2):
>     pData[i/2] = int(destAddress[i:i+2], 16)
> 
> pattern = 0xAAAAAAAA
> for i in range(  512):
>     pData[i+6] = long(pattern, 16)
> print pData
> 
> OverflowError: long int too large to covert to int
> 
> def test(pData.buffer_info()[0])
>     ....
>     ....
> Any help appreciated.
> -Ashton
> 
> --
> http://mail.python.org/mailman/listinfo/python-list
> 


-- 
Christopher Lambacher
lambacck at computer.org



More information about the Python-list mailing list