def get_txt_pydns(name):
    """Return a TXT record associated with a DNS name."""
    # Older pydns releases don't like a trailing dot.
    if name.endswith('.'):
        name = name[:-1]
    response = DNS.DnsRequest(name, qtype='txt').req()
    if not response.answers:
        return None
    return b''.join(response.answers[0]['data'])
Return a TXT record associated with a DNS name.
python/dkim/dnsplug.py