[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Discuss-gnuradio] array to string conversion (packet_utils.py)

From: Eric Blossom
Subject: Re: [Discuss-gnuradio] array to string conversion (packet_utils.py)
Date: Tue, 28 Mar 2006 11:56:48 -0800
User-agent: Mutt/1.5.9i

On Tue, Mar 28, 2006 at 07:32:15PM +0200, Luis Simoes wrote:
> Hi everybody,
> do somebody know how to convert a list or an array to a string when changed 
> the size of the items?
> I use the packet_utils.py where i changed the functions whiten(s). First I 
> slice the string s into UnsignedInt8 items into a list sa (as done in the 
> original source code). Then I map a function to this list and it results in 
> 16 bit items of the new list z. When I try to use z.tostring() method it 
> doesn't work. The str(z) function also gives wrong results. How can I join 
> this 16bit items to one string? the number of elements in z is variable. And 
> the resulting string should be slices in a new function into UnsignedInt8 or 
> Int16 intems.
> I could not find anything in the python docs and tutorials that resolves my 
> problem.
> Thanks for any advice,
> Luis

Hi Luis,

.tostring is from Numeric and only works on 8-bit arrays.
As written, whiten just xors with a fixed pattern.
You could get to strings using the python struct.pack method, or
converting your sequence of N 16-bit items to 2*N 8-bit items, then
working with those.  It all depends on what you're trying to do.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]