newbe: tuple

david brochu jr brochu121 at gmail.com
Wed Jun 14 10:18:06 EDT 2006


I am trying to get my ip address through a script and I am using the
following code:

import socket

ip = socket.gethostbyaddr(socket.gethostname())



ip then becomes a tuple and takes on three values. I am trying to pull the
value of ip[2] which when printed displays:
['10.5.100.17'].

I want this ip that is being returned, but I would like it as a string,
without the [' and ']. Any idea how I would trim this down?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20060614/3a8a7752/attachment.html>


More information about the Python-list mailing list