[Pyrex] Handling bytes

Brad Schick schickb at gmail.com
Thu May 8 08:21:21 CEST 2008


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.copyleft.no/pipermail/pyrex/attachments/20080508/e6b3388c/attachment.html 


More information about the Pyrex mailing list