6.1 DNR Result Objects

Since the DNR calls all execute asynchronously you do not get the results back immediately. Instead, you get a dnr result object. You can check this object to see whether the query is complete, and access its attributes to obtain the information when it is.

Alternatively, you can also reference the result attributes directly, this will result in an implicit wait for the query to complete.

The rtnCode and cname attributes are always available, the others depend on the type of query (address, hinfo or mx).

wait ()
Wait for the query to complete.

isdone ()
Return 1 if the query is complete.

The error code returned by the query.

The canonical name of the host that was queried.

At most four integer IP addresses for this host. Unused entries are zero. Valid only for address queries.

Textual strings giving the machine type an OS name. Valid for ``hinfo'' queries.

The name of a mail-exchanger host. Valid for ``mx'' queries.

The preference of this mx record. Not too useful, since the Macintosh will only return a single mx record. Valid for ``mx'' queries only.

The simplest way to use the module to convert names to dotted-decimal strings, without worrying about idle time, etc:

>>> def gethostname(name):
...     import macdnr
...     dnrr = macdnr.StrToAddr(name)
...     return macdnr.AddrToStr(dnrr.ip0)

Send comments on this document to python-docs@python.org.