def resolve(*args):
    """Resolve a sequence of IP addresses to their hostnames, if possible."""
    if len(args) > 1:
        addrList = args
    else:
        addrList = args[0]
    for addr in addrList:
        if isinstance(addr, tuple):
            addr = addr[0]
        try:
            host = gethostbyaddr(addr)[0]
        except (herror, IndexError):
            host = addr
        print 'Addr: %s Hostname: %s' % ((addr+',').ljust(16), host)
Resolve a sequence of IP addresses to their hostnames, if possible.
recipes/Python/438809_Tracking_file_requests_web_server_access/recipe-438809.py