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

    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/65219_IP_address_conversion_functions/recipe-65219.py