code: def query(number, domains, resolver=None):
      
      if resolver is None:
          resolver = dns.resolver.get_default_resolver()
      for domain in domains:
          if isinstance(domain, (str, unicode)):
              domain = dns.name.from_text(domain)
          qname = dns.e164.from_e164(number, domain)
          try:
              return resolver.query(qname, 'NAPTR')
          except dns.resolver.NXDOMAIN:
              pass
      raise dns.resolver.NXDOMAIN
docs: Look for NAPTR RRs for the specified number in the specified domains.
  
      e.g. lookup('16505551212', ['e164.dnspython.org.', 'e164.arpa.'])