hostid?

Will Stuyvesant hwlgw at hotmail.com
Sat Oct 19 20:49:47 CEST 2002


[Lance]
> I'd like to retrieve a computer's hostid. Does anyone know how to do this?

socket.gethostname()

''Return a string containing the hostname of the machine where the
Python interpreter is currently executing. If you want to know the
current machine's IP address, you may want to use
gethostbyname(gethostname()). This operation assumes that there is a
valid address-to-host mapping for the host, and the assumption does
not always hold. Note: gethostname() doesn't always return the fully
qualified domain name; use gethostbyaddr(gethostname()) ''

>From the Reference Manual in your Python distro.

Works like a charm on Windows; I have NT and XP.  Linux sometimes has
problems with that address-to-host mapping since linux is so hard to
configure.

'''
The program said "Requires Windows 9x or better", so I installed
Linux.
'''



More information about the Python-list mailing list