Is there a best practice for making deeply nested structure references readable?


Today I came across this perfectly normal line of code in our codebase and it made me angry:

try:
    import dns.resolver
    url = dns.resolver.query(fqdn,"TXT").response.answer(0)(-1).strings(0)

(first two lines included to meet the arbitrary 3-line requirement)

It does the right thing and it is not obvious to me how the person who wrote it should have done it better. But nevertheless, as a reviewer, I have no idea whether it’s right or not.

Some ideas that come to mind are linking the docs for the response format in a comment, or just describing it in a comment. Are there other standard ways of making references like this more legible?