def get_net(net): if isinstance(net, (ipaddr.IPv4Network, ipaddr.IPv6Network)): return net return ipaddr.IPNetwork(net)