How to represent a sequence of raw bytes

Steven Woody narkewoody at gmail.com
Mon Dec 22 01:56:45 EST 2008


On Mon, Dec 22, 2008 at 10:27 AM, Michiel Overtoom <motoom at xs4all.nl> wrote:
> On Monday 22 December 2008 03:23:03 Steven Woody wrote:
>
>> 2.  char buf[] = {0x11, 0x22, 0x33, ... }
>>
>> What's the equivalent representation for above in Python?
>
>>>> buf="\x11\x22\33"
>>>> for b in buf: print ord(b)
> ...
> 17
> 34
> 27
>>>>
>

Hi, Michiel

I thing "\x11\x22\x33" in python is not the {0x11, 0x22, 0x33} in C.
Since, a string in python is immutable, I can _not_ do something like:
 b[1] = "\x55".

And, how about char buf[200] in my original question?  The intension
is to allocate 200 undefined bytes in memory. Thanks.

Regards,



More information about the Python-list mailing list