[EMAIL PROTECTED] wrote: > Try... > >>>> for i in bytes: print ord(i) > > or > >>>> len(bytes) > > What you see isn't always what you have. Your database is capable of > storing \ x 0 0 characters, but your string contains a single byte of > value zero. When Python displays the string representation to you, it > escapes the values so they can be displayed.
He can still store the repr of the string into the database, and then reconstruct it with eval: >>> bytes = "\x00\x01\x02" >>> bytes '\x00\x01\x02' >>> len(bytes) 3 >>> ord(bytes[0]) 0 >>> rb = repr(bytes) >>> rb "'\\x00\\x01\\x02'" >>> len(rb) 14 >>> rb[0] "'" >>> rb[1] '\\' >>> rb[2] 'x' >>> rb[3] '0' >>> rb[4] '0' >>> bytes2 = eval(rb) >>> bytes == bytes2 True -- Giovanni Bajo -- http://mail.python.org/mailman/listinfo/python-list