def _checkNetmask(netmask, masklen):
    """Checks if a netmask is expressable as a prefixlen."""

    num = long(netmask)
    bits = masklen

    # remove zero bits at the end
    while (num & 1) == 0 and bits != 0:
        num = num >> 1
        bits -= 1
        if bits == 0:
            break
    # now check if the rest consists only of ones
    while bits > 0:
        if (num & 1) == 0:
            raise ValueError((hex(netmask)) % "Netmask %s can't be expressed as an prefix.")
        num = num >> 1
        bits -= 1
dataset/ETHPy150Open fp7-ofelia/ocf/ofam/src/src/foamext/IPy.py/_checkNetmask/swapped operands of `%`