summaryrefslogtreecommitdiff
path: root/tutorials
diff options
context:
space:
mode:
authorNaveen Nathan <naveen@lastninja.net>2016-05-14 13:21:11 +1000
committerJakub Stasiak <jakub@stasiak.at>2020-06-21 01:32:00 +0200
commitb08dcb6e72dbe6b35eb96417f2af7657b0839a42 (patch)
treefa8b48b614498a4068a3c6509fef08fa0482feaf /tutorials
parent87d14ee48dfe0950ac92e54d2636ec47474a1f02 (diff)
downloadnetaddr-b08dcb6e72dbe6b35eb96417f2af7657b0839a42.tar.gz
add property setter for netmask for IPNetwork()
Diffstat (limited to 'tutorials')
-rw-r--r--tutorials/2.x/ip/tutorial.txt11
1 files changed, 11 insertions, 0 deletions
diff --git a/tutorials/2.x/ip/tutorial.txt b/tutorials/2.x/ip/tutorial.txt
index 2c577c8..797da55 100644
--- a/tutorials/2.x/ip/tutorial.txt
+++ b/tutorials/2.x/ip/tutorial.txt
@@ -113,6 +113,17 @@ IPNetwork('192.0.2.1/0')
>>> ip
IPNetwork('192.0.2.1/23')
+The prefix length can also be changed by specifying a subnet mask:
+
+>>> ip = IPNetwork('192.168.1.0/24')
+>>> ip.netmask = '255.255.0.0'
+>>> ip
+IPNetwork('192.168.1.0/16')
+>>> ip = IPNetwork('fe80::dead:beef/64')
+>>> ip.netmask = 'ffff:ffff::'
+>>> ip
+IPNetwork('fe80::dead:beef/32')
+
There is also a property that lets you access the *true* CIDR address which removes all host bits from the network address based on the CIDR subnet prefix.
>>> ip.cidr