[Tutor] [tutor] ipconfig

Jason Massey jason.massey at gmail.com
Thu Aug 10 15:55:27 CEST 2006


I found this on an artima forum:

http://www.artima.com/forums/flat.jsp?forum=181&thread=113874

This worked on my machine (win xp):

socket.getaddrinfo(socket.gethostname(), None)[0][4][0]

On 8/10/06, emilia12 at mail.bg <emilia12 at mail.bg> wrote:
>
> hello list
>
> is there in python an independent from the system way to
> obtain the IP
>
> i am playng around
> <code>
> import sys
> import os
> ipconfname={'nt':'ipconfig', 'posix':'ifconfig'}
> ipstr = os.popen(ipconfname[os.name] ).read()
> #print ipstr
> </code>
> but i found out that answer depends on os.name ...
>
> in this case i have to use a different parser for each
> system ... so is there another way to retrieve the IP?
>
> regards,
> e.
>
> -----------------------------
>
> http://www.atol.bg - Намери бившите си съученици и стари приятели!
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20060810/505c7deb/attachment.htm 


More information about the Tutor mailing list