Re: How to represent a sequence of raw bytes

2008-12-22 Thread Steven Woody
On Tue, Dec 23, 2008 at 5:05 AM, John Machin wrote: > On Dec 23, 1:52 am, "Steven Woody" wrote: >> On Mon, Dec 22, 2008 at 6:44 PM, Steven D'Aprano >> >> wrote: >> > On Mon, 22 Dec 2008 14:56:45 +0800, Steven Woody wrote: >> >> >> The intension is to allocate 200 undefined bytes in memory. >> >>

Re: How to represent a sequence of raw bytes

2008-12-22 Thread John Machin
On Dec 23, 1:52 am, "Steven Woody" wrote: > On Mon, Dec 22, 2008 at 6:44 PM, Steven D'Aprano > > wrote: > > On Mon, 22 Dec 2008 14:56:45 +0800, Steven Woody wrote: > > >> The intension is to allocate 200 undefined bytes in memory. > > > You *want* undefined bytes? Out of curiosity, what do you in

Re: How to represent a sequence of raw bytes

2008-12-22 Thread Grant Edwards
On 2008-12-22, Steven D'Aprano wrote: > On Mon, 22 Dec 2008 14:56:45 +0800, Steven Woody wrote: > >> The intension is to allocate 200 undefined bytes in memory. > > You *want* undefined bytes? Out of curiosity, what do you intend to do > with them? Predict the future, of course. -- Grant Edwar

Re: How to represent a sequence of raw bytes

2008-12-22 Thread Steven Woody
On Mon, Dec 22, 2008 at 6:44 PM, Steven D'Aprano wrote: > On Mon, 22 Dec 2008 14:56:45 +0800, Steven Woody wrote: > >> The intension is to allocate 200 undefined bytes in memory. > > You *want* undefined bytes? Out of curiosity, what do you intend to do > with them? > to receive/send network pack

Re: How to represent a sequence of raw bytes

2008-12-22 Thread Steven D'Aprano
On Mon, 22 Dec 2008 14:56:45 +0800, Steven Woody wrote: > The intension is to allocate 200 undefined bytes in memory. You *want* undefined bytes? Out of curiosity, what do you intend to do with them? -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: How to represent a sequence of raw bytes

2008-12-22 Thread bieffe62
On 22 Dic, 03:23, "Steven Woody" wrote: > Hi, > > What's the right type to represent a sequence of raw bytes.  In C, we usually > do > > 1.  char buf[200]  or > 2.  char buf[] = {0x11, 0x22, 0x33, ... } > > What's the equivalent representation for above in Python? > > Thanks. > > - > narke Usual

Re: How to represent a sequence of raw bytes

2008-12-22 Thread Steven Woody
On Mon, Dec 22, 2008 at 4:35 PM, James Mills wrote: > On Mon, Dec 22, 2008 at 4:56 PM, Steven Woody wrote: >> 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

Re: How to represent a sequence of raw bytes

2008-12-22 Thread James Mills
On Mon, Dec 22, 2008 at 4:56 PM, Steven Woody wrote: > 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 al

Re: How to represent a sequence of raw bytes

2008-12-21 Thread Hrvoje Niksic
"Steven Woody" writes: > What's the right type to represent a sequence of raw bytes. In C, > we usually do > > 1. char buf[200] or > 2. char buf[] = {0x11, 0x22, 0x33, ... } > > What's the equivalent representation for above in Python? import array buf = array.array('b', [0x11, 0x22, ...])

Re: How to represent a sequence of raw bytes

2008-12-21 Thread Chris Rebert
On Sun, Dec 21, 2008 at 10:56 PM, Steven Woody wrote: > On Mon, Dec 22, 2008 at 10:27 AM, Michiel Overtoom 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? >> >

Re: How to represent a sequence of raw bytes

2008-12-21 Thread Tino Wildenhain
Steven Woody wrote: On Mon, Dec 22, 2008 at 10:27 AM, Michiel Overtoom 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" ... I thing "\x11\x22\x33" in python

Re: How to represent a sequence of raw bytes

2008-12-21 Thread Steven Woody
On Mon, Dec 22, 2008 at 10:27 AM, Michiel Overtoom 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 > 3

Re: How to represent a sequence of raw bytes

2008-12-21 Thread Michiel Overtoom
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 >>> Greetings, -- "The ability of the OSS process to collect and