python socket usage

markacy markacy at gmail.com
Thu Aug 16 03:53:59 EDT 2007


On 16 Sie, 09:42, O uz Yar mtepe <comp.... at gmail.com> wrote:
> Is it possible to send a data object like a tuple or a list in socket
> programming? If so how? It seems with socket module it is only possible to
> send strings.
>
> --
> O uz Yar mtepehttp://www.yarimtepe.com/en

Hi Oguz,

   why don't you make a string out of your tuple, or list, send it via
socket and make a tuple/list again?

>>> x = (1,2,3,4,5,6,7,)
>>> type(x)
<type 'tuple'>
>>> y = str(x)
>>> type(y)
<type 'str'>
>>> print y
(1, 2, 3, 4, 5, 6, 7)
>>> z = tuple(y)
>>> type(z)
<type 'tuple'>
>>>

Cheers,
Marek




More information about the Python-list mailing list