MCPcopy Index your code
hub / github.com/python/cpython / is_private

Method is_private

Lib/ipaddress.py:2090–2111  ·  view source on GitHub ↗

``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_private`` is ``False`` for ``100.64.0.0/10`` * For IPv4-mapped IPv6-addresses the ``

(self)

Source from the content-addressed store, hash-verified

2088 @property
2089 @functools.lru_cache()
2090 def is_private(self):
2091 """``True`` if the address is defined as not globally reachable by
2092 iana-ipv4-special-registry_ (for IPv4) or iana-ipv6-special-registry_
2093 (for IPv6) with the following exceptions:
2094
2095 * ``is_private`` is ``False`` for ``100.64.0.0/10``
2096 * For IPv4-mapped IPv6-addresses the ``is_private`` value is determined by the
2097 semantics of the underlying IPv4 addresses and the following condition holds
2098 (see :attr:`IPv6Address.ipv4_mapped`)::
2099
2100 address.is_private == address.ipv4_mapped.is_private
2101
2102 ``is_private`` has value opposite to :attr:`is_global`, except for the ``100.64.0.0/10``
2103 IPv4 range where they are both ``False``.
2104 """
2105 ipv4_mapped = self.ipv4_mapped
2106 if ipv4_mapped is not None:
2107 return ipv4_mapped.is_private
2108 return (
2109 any(self in net for net in self._constants._private_networks)
2110 and all(self not in net for net in self._constants._private_networks_exceptions)
2111 )
2112
2113 @property
2114 def is_global(self):

Callers

nothing calls this directly

Calls 1

anyFunction · 0.70

Tested by

no test coverage detected