def ipToNetAndHost(ip, maskbits):
    "returns tuple (network, host) dotted-quad addresses given IP and mask size"
    # (by Greg Jorgensen)

    n = dottedQuadToNum(ip)
    m = makeMask(maskbits)

    host = n & m
    net = n - host

    return numToDottedQuad(net), numToDottedQuad(host)
returns tuple (network, host) dotted-quad addresses given IP and mask size
recipes/Python/66517_IP_address_conversifunctions_builtsocket/recipe-66517.py