[EMAIL PROTECTED] wrote: > This is a bit of a peculiar problem. First off, this relates to Python > Challenge #12, so if you are attempting those and have yet to finish > #12, as there are potential spoilers here. > > I have five different image files shuffled up in one big binary file. > In order to view them I have to "unshuffle" the data, which means > moving bytes around. Currently my approach is to read the data from the > original, unshuffle as necessary, and then write to 5 different files > (2 .jpgs, 2 .pngs and 1 .gif). > > The problem is with the read() method. If I read a byte valued as 0x00 > (in hexadecimal), the read method returns a character with the value > 0x20.
No. It doesn't. Ok, maybe it does, but I doubt this so severely that, without even checking, I'll bet you a [virtual] beer it doesn't. :-) Are you opening the file in binary mode? Ok, I did check, it doesn't. |>> s = '\0' |>> len(s) 1 |>> print s \x00 |>> f = open('noway', 'wb') |>> f.write(s) |>> f.close() Checking that the file is a length 1 null byte: $ hexdump noway 0000000 0000 0000001 $ ls -l noway -rw-r--r-- 1 sforman sforman 1 2006-08-03 23:40 noway Now let's read it and see... |>> f = open('noway', 'rb') |>> s = f.read() |>> f.close() |>> len(s) 1 |>> print s \x00 The problem is not with the read() method. Or, if it is, something very very weird is going on. If you can do the above and not get the same results I'd be interested to know what file data you have, what OS you're using. Peace, ~Simon (Think about this: More people than you have tried the challenge, if this happened to them they'd have mentioned it too, and it would have fixed or at least addressed by now. Maybe.) (Hmm, or maybe this is *part* of the challenge?) -- http://mail.python.org/mailman/listinfo/python-list