Re: Handling bytes

Brad Schick <[email protected]>
Newsgroups gmane.comp.python.pyrex
Message-ID <[email protected]>
On 5/7/2008 10:49 PM, Stefan Behnel wrote:
> Hi,
>
> Brad Schick wrote:
>   
>> Maybe I'd be better off using python strings
>> with  PyString_FromStringAndSize and friends?
>>     
>
> Yes.
>   

I guess strings a byte arrays is part of pre 3.0 python. It just seems 
so ugly in what is otherwise a fairly clean language. Particularly when 
the data sometimes starts life as a list. How do you go about stuffing 
'bytes' into a string? With arrays as below? Or with cStringIO? Yuck and 
yuck ;)

data = [0,1,2,3,4,5,6,7]
arr = array.array('B', data)
str = arr.tostring()


-Brad

_______________________________________________
Pyrex mailing list
[email protected]
http://lists.copyleft.no/mailman/listinfo/pyrex
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.