On 2005-03-21, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:

> msg = "Length is "
> n = '\x81'
> msg += n
> sock.send(msg)
>
> The problem is n's value is not fixed. For example,
>
> msg = "Length is "
> n = len(somestring)
> msg += n  # This won't work of course, since n is int
>
> How do I send this msg + n?

n = 0x81
msg = "Length is " + chr(n)

That only works for "hex numbers" than can be properly encoded
as a character in the default encoding.

See the "struct" module for a more general solution.

-- 
Grant Edwards                   grante             Yow!  There's a lot of BIG
                                  at               MONEY in MISERY if you have
                               visi.com            an AGENT!!
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to