[Tutor] IP Address from Python module?

Terry Carroll carroll at tjc.com
Sat Aug 6 01:51:14 CEST 2005

On Fri, 5 Aug 2005, Joseph Quigley wrote:

> Is it possible to get my internet and/or network IP address from Python?

import socket
ipaddr = socket.gethostbyname(socket.gethostname())

Some users report this gives a meaningless '' (i.e., localhost), 
though.  But try it and see.  It works for me.

More information about the Tutor mailing list