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

socket.inet_ntop

Prev: socket.inet_ntoa | Up: socket | Next: socket.inet_pton
Rel: socket.AddressFamily, socket.close, socket.create_connection, socket.create_server
Ref: docs.python.org — socket.inet_ntop
Tags: #public #python3 #stdlib #socket


Import

import socket
from socket import inet_ntop

Signature & Overview

socket.inet_ntop(af, packed_ip) -> string formatted IP address

Convert a packed IP address of the given family to string format.

Usage

import socket

assert socket.inet_ntop(socket.AF_INET, b"\x0a\x00\x00\x01") == "10.0.0.1"
assert socket.inet_ntop(socket.AF_INET6, b"\x00" * 15 + b"\x01") == "::1"

Gotchas

REPL Inspect

from socket import inet_ntop
help(inet_ntop)

Linked from

Related notes