On this page
socket.sethostname
Prev: socket.setdefaulttimeout | Up: socket | Next: socket.socket
Rel: socket.AddressFamily, socket.close, socket.create_connection, socket.create_server
Ref: docs.python.org — socket.sethostname
Tags: #public #python3 #stdlib #socket
Import
import socket
from socket import sethostname
Signature & Overview
socket.sethostname(name)
Sets the hostname to name.
Usage
import socket
# Unix-only privileged call to change the system hostname
assert hasattr(socket, "sethostname") or True
Gotchas
- Requires root/administrator privileges: Raises
PermissionErrorfor normal users.
REPL Inspect
from socket import sethostname
help(sethostname)
Linked from
Related notes
- tuts/python3/stdlib_module/socket/setdefaulttimeout Linked here; links to this page; shared tags: #socket, #stdlib
- tuts/python3/stdlib_module/socket/socket Linked here; links to this page; shared tags: #socket, #stdlib
- tuts/python3/stdlib_module/socket/AddressFamily Linked here; shared tags: #socket, #stdlib
- tuts/python3/stdlib_module/socket/close Linked here; shared tags: #socket, #stdlib
- tuts/python3/stdlib_module/socket/create_connection Linked here; shared tags: #socket, #stdlib
- tuts/python3/stdlib_module/socket/create_server Linked here; shared tags: #socket, #stdlib
- tuts/python3/stdlib_module/socket links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/socket/dup shared tags: #socket, #stdlib
- tuts/python3/stdlib_module/socket/error shared tags: #socket, #stdlib
- tuts/python3/stdlib_module/socket/fromfd shared tags: #socket, #stdlib