Set the machine’s hostname to name. This will raise an OSError if you don’t have enough rights.
socket.sethostname(name)