Entry
Detecting own computer's IP
How do I go about getting my dynamic IP address?
Jul 5th, 2000 10:01
Nathan Wallace, unknown unknown, Hans Nowak, Snippet 188, Python Snippet Support Team
"""
Packages: networking.sockets
"""
""" detectip.py
Detects your own IP address. No big deal on Python; more work on Delphi
(where the code originated from :).
"""
import socket
def detectip():
buf = socket.gethostname()
remotehost = socket.gethostbyname(buf)
return remotehost
if __name__ == "__main__":
print "Your IP address is", detectip()
raw_input()