Daniel Flick wrote: > I am very new to Python and have been struggling to find some info on > processing IP addresses. > > get_network returns 192.168.1.128/25 but I need 192.168.1.128 only. I can > do this with netaddr but I am working with Mako templates and ipaddress is > a built in module so there are less dependencies. > > Any ideas?
You mean you have >>> import ipaddress >>> n = ipaddress.ip_network("192.168.1.128/25") >>> n IPv4Network('192.168.1.128/25') ? Then one >>> dir(n) [snip private names] '_version', 'address_exclude', 'broadcast_address', 'compare_networks', 'compressed', 'exploded', 'hostmask', 'hosts', 'is_global', 'is_link_local', 'is_loopback', 'is_multicast', 'is_private', 'is_reserved', 'is_unspecified', 'max_prefixlen', 'netmask', 'network_address', 'num_addresses', 'overlaps', 'prefixlen', 'subnets', 'supernet', 'version', 'with_hostmask', 'with_netmask', 'with_prefixlen'] later: >>> n.network_address IPv4Address('192.168.1.128') -- https://mail.python.org/mailman/listinfo/python-list