I'm trying to do a zonetransfer with dnspython
, and then store the A record's into a dictionary that i can pop values from later. See below:
import dns.zone
import dns.query
from dns.exception import DNSException
from dns.rdataclass import *
from dns.rdatatype import *
domain = "mydomain.com"
ns = '1.2.3.4'
try:
zone = dns.zone.from_xfr(dns.query.xfr(ns, domain))
print "Zone origin:", zone.origin
except DNSException, e:
print e.__class__, e
for (name, ttl, rdata) in zone.iterate_rdatas('A'):
record = { name : rdata }
print name, rdata
print record
why is the output when i use print
is different than when i store the same variables name, rdata
in a dictionary, and print that dict? See output below:
www 1.1.1.1
{<DNS name www>: <DNS IN A rdata: 1.1.1.1>}
I guess to clarify my question: How do I make the dict look like :
{ 'www' : '1.1.1.1' }