I am using easyzone and dnspython to extract DNS records from a zone file. When extracting A records I am given back a string and an object in a tuple. I am new to Python coming from PHP and am not quite sure how to get at this object to get the value of it? I had no problems getting the string value in the tuple.
In this code snippet I iterate through the A records and write the values into a CSV:
# Write all A records
for a in z.names.items():
c.writerow([domain, 'A', a.__getitem__(0), a])
a contains the following:
('www.121dentalcare.com.', <easyzone.easyzone.Name object at 0x1012dd190>)
How would I access this object within a which is in the 2nd half of this tuple??
You can use indices to get items from a tuple:
just as you can do with lists and strings (see sequence types).
The documentation of
easyzoneis a little on the thin side, but from looking at the source code it appears theeasyzone.easyzone.Nameobjects have.name,.soaand.ttlattributes:The
.soaattribute is another custom class, with.mname,.rname,.serial,.refresh,.retry,.expireand.minttlproperties.