def gen_ipaddr(ip3=False, ipv6=False, prefix=()):

    # Set the lengths of the randomly generated sections
    if ipv6:
        rng = 8
    elif ip3:
        rng = 3
    else:
        rng = 4
    prefix = [str(field) for field in prefix]
    # Prefix reduces number of random fields generated, so subtract the length
    # of it from the rng to keep the IP address have correct number of fields
    rng -= len(prefix)
    if rng == 0:
        raise ValueError(
            "Prefix {} would lead to no randomness at all".format(
                repr(prefix)))
    elif rng < 0:
        raise ValueError(
            "Prefix {} is too long for this configuration".format(
                repr(prefix)))

    random.seed()

    if ipv6:
        # StackOverflow.com questions: generate-random-ipv6-address
        random_fields = [
            '{0:x}'.format(random.randint(0, 2**16 - 1)) for _ in range(rng)]
        ipaddr = u':'.join(prefix + random_fields)
    else:
        random_fields = [str(random.randrange(0, 255, 1)) for _ in range(rng)]
        ipaddr = u".".join(prefix + random_fields)

        if ip3:
            ipaddr = ipaddr + u".0"

    return _make_unicode(ipaddr)
Greet someone.
dataset/ETHPy150Open omaciel/fauxfactory/fauxfactory/__init__.py/gen_ipaddr--crossover with--dataset/ETHPy150Open tellapart/commandr/example.py/SayGreeting