Skip to content

Instantly share code, notes, and snippets.

@dfilimon
Created December 4, 2010 12:58
Show Gist options
  • Save dfilimon/728161 to your computer and use it in GitHub Desktop.
Save dfilimon/728161 to your computer and use it in GitHub Desktop.
Getting all IP addresses of a particular machine in Python. Unfortunately it doesn't work properly in Linux without a properly configured /etc/hosts file.
self.ip = [ip for ip in socket.gethostbyname_ex(socket.gethostname())[2] if not ip.startswith("127.")][0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment