Subprocess puzzle and two questions

Kushal Kumaran kushal.kumaran+python at gmail.com
Wed Nov 14 23:53:08 EST 2012


Chris Angelico <rosuav at gmail.com> writes:

> On Thu, Nov 15, 2012 at 12:49 PM, Roy Smith <roy at panix.com> wrote:
>> In article <mailman.3700.1352930072.27098.python-list at python.org>,
>>  Chris Angelico <rosuav at gmail.com> wrote:
>>
>>> I'm slightly surprised that there's no way with the Python stdlib to
>>> point a DNS query at a specific server
>>
>> Me too, including the "only slightly" part.  The normal high-level C
>> resolver routines (getaddrinfo/getnameinfo, or even the old
>> gethostbyname series), don't expose any way to do that.  You have to dig
>> quite far down in the resolver library stack to get to the point where
>> you can do that.  The concept of not knowing or caring which specific
>> server has the data you need is quite deeply baked into the basic DNS
>> architecture.
>
> Indeed. But Python boasts that the batteries are included, and given
> the wealth of other networking facilities that are available, it is a
> bit of a hole that you can't run DNS queries in this way.
>
> Mind you, if Python's managed to get this far without it being a major
> stumbling-block, that probably means that it's not a serious lack. And
> I don't think many people write DNS *servers* in Python. (Most people
> don't write DNS servers at all, since BIND exists. But I did exactly
> that this week, since it would be easier than most other options.)
>

Indeed.  Most people would prefer if random applications didn't make
their own decisions about using specific DNS servers.  That way, the
users can make their own configuration choices (gai.conf, nsswitch.conf)
according to their site preferences.

If your application needs that level of control (if you're writing a
nslookup replacement for some reason, perhaps), dnspython
(www.dnspython.org) seems to have it.

-- 
regards,
kushal



More information about the Python-list mailing list