On this page
  1. socket.gethostname
  2. Import
  3. Signature & Overview
  4. Usage
  5. Gotchas
  6. REPL Inspect

socket.gethostname

Prev: socket.gethostbyname_ex | Up: socket | Next: socket.getnameinfo
Rel: socket.AddressFamily, socket.close, socket.create_connection, socket.create_server
Ref: docs.python.org — socket.gethostname
Tags: #public #python3 #stdlib #socket


Import

import socket
from socket import gethostname

Signature & Overview

socket.gethostname()

Return the current host name.

Usage

import socket

name = socket.gethostname()
assert isinstance(name, str) and len(name) > 0

Gotchas

REPL Inspect

from socket import gethostname
help(gethostname)

Linked from

Related notes