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

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


''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

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

More information about the Python-list mailing list