I am parsing DNS packets using scapy. Not all of the DNS Answer Records have all of the fields. For example, some Answers don't have rdata so
answer = packet.an.rdata
You could always do a try-except. Might not be as slick as what you're looking for, though.
try: answer = packet.an.rdata except AttributeError: # do something