[CentralOH] Local IP Address in Python
mark at microenh.com
Wed May 18 18:12:40 CEST 2011
On May 18, 2011, at 8:08 AM, Mark Erbaugh wrote:
> Is there a Python library function to determine the IP address or addresses of the local machine? I'm looking for something that provides the information similar to what is displayed when you run ifconfig (Posix) or ipconfig (Windows)?
I'll answer my own question for others who might be interested:
x = [i for i in socket.getaddrinfo(socket.gethostname(), None, socket.AF_INET, socket.SOCK_STREAM)]
This seems to work on both my Mac and Windows.
More information about the CentralOH