converting an array of chars to a string

Bengt Richter bokr at oz.net
Mon Jun 24 15:00:21 EDT 2002


On Mon, 24 Jun 2002 19:40:17 +0200, JB <jblazi at hotmail.com> wrote:

>Bengt Richter wrote:
>> No cause for desperation ;-)
>> 
>> Are you saying that you want modulo 256 arithmetic on
>> unsigned 8-bit data? No problem. But what does your data
>> represent? And what does adding a number to such a data
>> item mean in the real world?
>
>Of course you are right. I really needed only some 8-bit 
>shifting. The point is, that there is no need for the 
>overhead that is involved. If anybody uses the array module 
>which, you can argue, is a low level module, he should know 
>what he is doing.
>
It is hard to be very helpful without knowing the "big picture."
You originally said:

"How can I convert an array of chars to string?

The problem is this: I should like to perform 8 bit 
calculations in a buffer. After this has been done, the 
buffer has to ba written to a binary file (and file.write 
takes strings instead of lists)."

And I still have no idea why you want to do that, or what your
data represents, or how much of it there is, or where it comes
from, or how fast and/or often you have to process it.

Who knows, there may be a whole application out there that
does what you want, and more. But a narrow question about
8 bit calculations and buffers and binary files will not
generally evoke the association, unless someone happens to be
doing an implementation, and says, "Hey, that's just what I'm working
on in my blarglefoo framework. Are you by any chance working
on a similar app? It's for processing ..."

I'm not intending to criticize, I'm just trying to point out a typical
feature of newsgroup technical questions. They tend to say, "I need
a fast square root" and leave out that they don't have floating point
(ok, that'd be a probable inference), and they are checking distances
between things against a threshold. Whereas if they'd revealed what they
were trying to do, it could've been pointed out that they didn't need a
square root at all (just compare with the threshold distance squared).

Anyway, good luck with it ;-)

Regards,
Bengt Richter



More information about the Python-list mailing list