PyDocs

Nav

Internet Protocols and Support

IPv4Address

  • IPv4Address(address)
Represent and manipulate single IPv4 Addresses.
Changed in 3.8, 3.9.5
  • 3.8: Leading zeros are tolerated, even in ambiguous cases that look like octal notation.
  • 3.9.5: Leading zeros are no longer tolerated and are treated as an error. IPv4 address strings are now parsed as strict as glibc inet_pton().
Members of IPv4Address

_

__format__
Returns an IP address as a formatted string.

c

compressed
Return the shorthand version of the IP address as a string.

e

exploded
Return the longhand version of the IP address as a string.

i

ipv6_mapped
Return the IPv4-mapped IPv6 address.
is_global
``True`` if the address is defined as globally reachable by iana-ipv4-special-registry_ (for IPv4) or iana-ipv6-special-registry_ (for IPv6) with the following exception:
is_link_local
Test if the address is reserved for link-local.
is_loopback
Test if the address is a loopback address.
is_multicast
Test if the address is reserved for multicast use.
is_private
``True`` if the address is defined as not globally reachable by iana-ipv4-special-registry_ (for IPv4) or iana-ipv6-special-registry_ (for IPv6) with the following exceptions:
is_reserved
Test if the address is otherwise IETF reserved.
is_unspecified
Test if the address is unspecified.

m

max_prefixlen
The total number of bits in the address representation for this version: 32 for IPv4, 128 for IPv6.

p

packed
The binary representation of this address.

r

reverse_pointer
The name of the reverse DNS pointer for the IP address, e.g.: >>> ipaddress.ip_address("127.0.0.1").reverse_pointer '1.0.0.127.in-addr.arpa' >>> ipaddress.ip_address("2001:db8::1").reverse_pointer '1…

v

version
The appropriate version number: 4 for IPv4, 6 for IPv6.
1 Example
>>> ipaddress.IPv4Address('192.168.0.1')
IPv4Address('192.168.0.1')
>>> ipaddress.IPv4Address(3232235521)
IPv4Address('192.168.0.1')
>>> ipaddress.IPv4Address(b'\xC0\xA8\x00\x01')
IPv4Address('192.168.0.1')
from the Python docs
See Also
No see-alsos for ipaddress/IPv4Address
0 Notes
No notes for IPv4Address