summaryrefslogtreecommitdiffstats
path: root/Doc/library/ipaddress.rst
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2014-05-12 18:36:46 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2014-05-12 18:36:46 (GMT)
commit5fb195f854e6fe016015c98dfd379c1102950c04 (patch)
tree34fb65e46690ef8542381fdb5315bd6ad93403ee /Doc/library/ipaddress.rst
parent3b5162d05d24a2f4cd6b2b9f5b503982cf433cd6 (diff)
downloadcpython-5fb195f854e6fe016015c98dfd379c1102950c04.zip
cpython-5fb195f854e6fe016015c98dfd379c1102950c04.tar.gz
cpython-5fb195f854e6fe016015c98dfd379c1102950c04.tar.bz2
Issue #16531: ipaddress.IPv4Network and ipaddress.IPv6Network now accept an (address, netmask) tuple argument, so as to easily construct network objects from existing addresses.
Diffstat (limited to 'Doc/library/ipaddress.rst')
-rw-r--r--Doc/library/ipaddress.rst19
1 files changed, 19 insertions, 0 deletions
diff --git a/Doc/library/ipaddress.rst b/Doc/library/ipaddress.rst
index 0bc27ff..6899cf6 100644
--- a/Doc/library/ipaddress.rst
+++ b/Doc/library/ipaddress.rst
@@ -392,6 +392,12 @@ so to avoid duplication they are only documented for :class:`IPv4Network`.
3. An integer packed into a :class:`bytes` object of length 4, big-endian.
The interpretation is similar to an integer *address*.
+ 4. A two-tuple of an address description and a netmask, where the address
+ description is either a string, a 32-bits integer, a 4-bytes packed
+ integer, or an existing IPv4Address object; and the netmask is either
+ an integer representing the prefix length (e.g. ``24``) or a string
+ representing the prefix mask (e.g. ``255.255.255.0``).
+
An :exc:`AddressValueError` is raised if *address* is not a valid IPv4
address. A :exc:`NetmaskValueError` is raised if the mask is not valid for
an IPv4 address.
@@ -404,6 +410,10 @@ so to avoid duplication they are only documented for :class:`IPv4Network`.
objects will raise :exc:`TypeError` if the argument's IP version is
incompatible to ``self``
+ .. versionchanged:: 3.5
+
+ Added the two-tuple form for the *address* constructor parameter.
+
.. attribute:: version
.. attribute:: max_prefixlen
@@ -568,6 +578,11 @@ so to avoid duplication they are only documented for :class:`IPv4Network`.
3. An integer packed into a :class:`bytes` object of length 16, bit-endian.
The interpretation is similar to an integer *address*.
+ 4. A two-tuple of an address description and a netmask, where the address
+ description is either a string, a 128-bits integer, a 16-bytes packed
+ integer, or an existing IPv4Address object; and the netmask is an
+ integer representing the prefix length.
+
An :exc:`AddressValueError` is raised if *address* is not a valid IPv6
address. A :exc:`NetmaskValueError` is raised if the mask is not valid for
an IPv6 address.
@@ -576,6 +591,10 @@ so to avoid duplication they are only documented for :class:`IPv4Network`.
then :exc:`ValueError` is raised. Otherwise, the host bits are masked out
to determine the appropriate network address.
+ .. versionchanged:: 3.5
+
+ Added the two-tuple form for the *address* constructor parameter.
+
.. attribute:: version
.. attribute:: max_prefixlen
.. attribute:: is_multicast