diff options
author | Charles Machalow <csm10495@gmail.com> | 2023-11-05 16:50:31 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-05 16:50:31 (GMT) |
commit | ba8aa1fd3735aa3dd13a36ad8f059a422d25ff37 (patch) | |
tree | 37338f169a6502ed9ccb371c07d7e4a23e58aaa6 /Lib/ipaddress.py | |
parent | 24b5cbd3dce3fe37cdc787ccedd1e73a4f8cfc3c (diff) | |
download | cpython-ba8aa1fd3735aa3dd13a36ad8f059a422d25ff37.zip cpython-ba8aa1fd3735aa3dd13a36ad8f059a422d25ff37.tar.gz cpython-ba8aa1fd3735aa3dd13a36ad8f059a422d25ff37.tar.bz2 |
gh-109466: Add ipv6_mapped property to IPv4Address (#109467)
Adds the `IPv4Address.ipv6_mapped` property.
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
Diffstat (limited to 'Lib/ipaddress.py')
-rw-r--r-- | Lib/ipaddress.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/ipaddress.py b/Lib/ipaddress.py index 68ddfbe..e398cc1 100644 --- a/Lib/ipaddress.py +++ b/Lib/ipaddress.py @@ -1389,6 +1389,16 @@ class IPv4Address(_BaseV4, _BaseAddress): """ return self in self._constants._linklocal_network + @property + def ipv6_mapped(self): + """Return the IPv4-mapped IPv6 address. + + Returns: + The IPv4-mapped IPv6 address per RFC 4291. + + """ + return IPv6Address(f'::ffff:{self}') + class IPv4Interface(IPv4Address): |