(x)
return "".join(res)
Take as input a list of DNS names or a single DNS name
    and encode it in DNS format (with possible compression)
    If a string that is already a DNS name in DNS format
    is passed, it is returned unmodified. Result is a string.
    !!!  At the moment, compression is not implemented  !!!
Take as input a list of DNS names or a single DNS name
    and encode it in DNS format (with possible compression)
    If a string that is already a DNS name in DNS format
    is passed, it is returned unmodified. Result is a string.
    !!!  At the moment, compression is not implemented  !!!
Take as input a list of DNS names or a single DNS name and encode it in DNS format ( with possible compression ) If a string that is already a DNS name in DNS format is passed it is returned unmodified . Result is a string . !!! At the moment compression is not implemented !!!
def names2dnsrepr(x):
    """
    Take as input a list of DNS names or a single DNS name
    and encode it in DNS format (with possible compression)
    If a string that is already a DNS name in DNS format
    is passed, it is returned unmodified. Result is a string.
    !!!  At the moment, compression is not implemented  !!!
    """
    
    if type(x) is str:
        if x and x[-1] == '\x00': # stupid heuristic
            return x
        x = [x]

    res = []
    for n in x:
        termin = "\x00"
        if n.count('.') == 0: # single-component gets one more
            termin += '\x00' 
        n = "".join(map(lambda y: chr(len(y))+y, n.split("."))) + termin
        res.append(n)
    return "".join(res)
def names2dnsrepr ( x ) : if type ( x ) is str : if x and x [ - 1 ] == '\x00' : # stupid heuristic return x x = [ x ] res = [ ] for n in x : termin = "\x00" if n . count ( '.' ) == 0 : # single-component gets one more termin += '\x00' n = "" . join ( map ( lambda y : chr ( len ( y ) ) + y , n . split ( "." ) ) ) + termin res . append ( n ) return "" . join ( res )