Added __len__ method to _BaseNetwork class in ipaddress module.
This enables a call such as random.choice(ipaddress.ip_network("192.169.0.0/16")).
This commit is contained in:
parent
78c7183f47
commit
da7d29347c
|
@ -750,6 +750,9 @@ class _BaseNetwork(_IPAddressBase):
|
|||
# address
|
||||
return other._ip & self.netmask._ip == self.network_address._ip
|
||||
|
||||
def __len__(self):
|
||||
return self.num_addresses
|
||||
|
||||
def overlaps(self, other):
|
||||
"""Tell if self is partly contained in other."""
|
||||
return self.network_address in other or (
|
||||
|
|
Loading…
Reference in New Issue