diff options
| author | Berker Peksag <berker.peksag@gmail.com> | 2016-06-11 19:11:47 (GMT) |
|---|---|---|
| committer | Berker Peksag <berker.peksag@gmail.com> | 2016-06-11 19:11:47 (GMT) |
| commit | 742192a4fea88b49633288fb6e5bea68cf0bdcc0 (patch) | |
| tree | 4f2dfeb88d76e4326d8d97ca712fdfefad23db44 /Lib/ipaddress.py | |
| parent | fa089b9b0b926c04e5d57812b7d7653472787965 (diff) | |
| download | cpython-742192a4fea88b49633288fb6e5bea68cf0bdcc0.zip cpython-742192a4fea88b49633288fb6e5bea68cf0bdcc0.tar.gz cpython-742192a4fea88b49633288fb6e5bea68cf0bdcc0.tar.bz2 | |
Issue #21386: Implement missing IPv4Address.is_global property
It was documented since 07a5610bae9d.
Initial patch by Roger Luethi.
Diffstat (limited to 'Lib/ipaddress.py')
| -rw-r--r-- | Lib/ipaddress.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/ipaddress.py b/Lib/ipaddress.py index ca3031a..1f90058 100644 --- a/Lib/ipaddress.py +++ b/Lib/ipaddress.py @@ -1312,6 +1312,11 @@ class IPv4Address(_BaseV4, _BaseAddress): return any(self in net for net in self._constants._private_networks) @property + @functools.lru_cache() + def is_global(self): + return self not in self._constants._public_network and not self.is_private + + @property def is_multicast(self): """Test if the address is reserved for multicast use. @@ -1557,6 +1562,8 @@ class _IPv4Constants: _multicast_network = IPv4Network('224.0.0.0/4') + _public_network = IPv4Network('100.64.0.0/10') + _private_networks = [ IPv4Network('0.0.0.0/8'), IPv4Network('10.0.0.0/8'), |
