def address(addr):
    """
    A special argument type that splits a string on ':' and transforms
    the result into a tuple of host and (integer) port.
    """
    if ':' in addr:
        host, _sep, port = addr.rpartition(':')
        try:
            port = int(port)
        except ValueError:
            raise ValueError('invalid port number %r' % port)
        addr = host, port
    return addr
