>>> addr6.exploded '2001:0db8:0000:0000:0000:0000:0000:0001' >>> addr6.compressed '2001:db8::1' >>> net6.exploded '2001:0db8:0000:0000:0000:0000:0000:0000/96' >>> net6.compressed '2001:db8::/96' >>> net4[1] IPv4Address('192.0.2.1') >>> net4[-1] IPv4Address('192.0.2.255') >>> net6[1] IPv6Address('2001:db8::1') >>> net6[-1] IPv6Address('2001:db8::ffff:ffff') >>> addr4=ipaddress.ip_address('192.0.2.1 ') >>> addr4 in ipaddress.ip_network( '192.0.2.0/24 ') True >>> addr4 in ipaddress.ip_network( '192.0.3.0/24 ') False While IPv4 doesn’t support explosion or compression, the associated objects still provide the relevant properties so that version neutral code can easily ensure the most concise or most verbose form is used for IPv6 addresses while still correctly handling IPv4 addresses. It’s sometimes useful to treat networks as lists. This means it is possible to index them like this: if address in network: # do something It also means that network objects lend themselves to using the list membership test syntax like this: Containment testing is done efficiently based on the network prefix: $_{ipaddress}$provides some simple, hopefully intuitive ways to compare objects, where it makes sense: >>> ipaddress.ip_address('192.0.2.1 ')<ipaddress.ip_address('192.0.2.2 ') True A$_{TypeError}$ exception is raised if you try to compare objects of different versions or different types. 5 4 Comparisons 3 Networks as lists of Addresses