'Initialize Addr from string.'

@classmethod
def fromstring(cls, str_addr):

    if str_addr.startswith('['):
        endIndex = str_addr.rfind(']')
        host = str_addr[:(endIndex + 1)]
        port = ''
        if ((len(str_addr) > (endIndex + 2)) and (str_addr[(endIndex + 1)] == ':')):
            port = str_addr[(endIndex + 2):]
        return cls((host, port), ipv6=True)
    else:
        tup = str_addr.partition(':')
        return cls((tup[0], tup[2]))
