> ....... is the decoding code, it does what you > describe below. It is adding the zeros back in, that > is the dst.append('\0') > > Kent
Really??? I am a noob, but it looks like it only puts a \0 at the end if code (the length) is less than 255, as the if statement is out of the for loop? this would be part of the coding algorithm, no? In that theme of writing, here is what I would do to make it decode: def UnStuffData(src,dst,len): if code == 0xFF: pass else: x = src(0) for code in src: for i in range(1,code): if i == x: dst.append('\0') x = src(i) else: dst.append(i) dst.pop(0) #remove first byte # if code < 0xff # dst.append('\0') -mike --- Kent Johnson <[EMAIL PROTECTED]> wrote: > Michael Cotherman wrote: > > def UnStuffData(src,dst,len): > > > > for code in src: > > for i in range(1,code): > > dst.append(i) > > > > if code < 0xff > > dst.append('\0') > > > > the above is the below code uncommented... > > it(and the original code) just seem to find the > end > > and puts a zero there... > > > > I do not see the existing zeroes replaced..... > this is > > kinda why I wanted to start from the > specification... > > The above is the decoding code, it does what you > describe below. It is adding the zeros back in, that > is the dst.append('\0') > > Kent > > > decoding is: > > pop the first byte of the packet off and place > > subsequent bytes into the output until you get to > the > > byte pointed to by the popped byte. When you reach > > that byte, read its value as the new 'relative' > > pointer, and copy x00 to the output. Proceed as > above, > > placing bytes to the output until the relative > pointer > > is reached or the end of the packet occurrs. > > > > I guess I need to look if I wish for this part of > the > > program to handle the input as one big existing > > string, or work on it a byte at a time as it comes > in. > > > > > > -mike c > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > __________________________________ Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.com _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor