Strings

John Machin sjmachin at lexicon.net
Thu Apr 21 19:38:48 EDT 2005


On Thu, 21 Apr 2005 21:16:43 +0800, Dan
<dan at dontspammecauseidontlikit.com> wrote:

>I've having trouble coming to grip with Python strings.
>
>I need to send binary data over a socket.  I'm taking the data from a
>database.  When I extract it, non-printable characters come out as a
>backslash followed by a three numeric characters representing the
>numeric value of the data.  

It would be very strange, but not beyond belief, for a DBMS to be
storing strings like that. What you are seeing is more likely an
artifact of how you are extracting it.  If this is so, it would be
better to avoid the complication and error-proneness of converting to
an octal[yuk!]-based representation and back again.

However if the DBMS *IS* storing strings like that, then it would
require a look in the DBMS docs PLUS a look at the empirical evidence
to produce a reliable transcoding.

If you were to tell us which DBMS, and supply a copy&paste snippet
(*NOT* a re-typing) of the *actual* extraction code that you are
using, then we should be able to help you further.

Cheers,

John





More information about the Python-list mailing list