Thank you (Cameron and Alan) for your review and feedback. This solved the issue perfectly! Thank you.
On Friday, October 2, 2015 11:49 PM, Cameron Simpson <c...@zip.com.au> wrote: On 03Oct2015 00:51, ALAN GAULD <alan.ga...@btinternet.com> wrote: >On 02/10/15 23:57, Nym City via Tutor wrote: >>socket.gaierror: [Errno 11004] getaddrinfo failed >... >>for name in ListOfHostNames: >> try: >> ResolveHostname = socket.gethostbyname(name) >> print(ResolveHostname) >> newFile.write(ResolveHostname + "\n") >> print(ResolveHostname) >> except socket.herror as e: >> newFile.write("No resolution available for %s" % (name) + "\n") > >You are catching herror but your code is resulting in gaierror. > >Add socket.gaierror to your except line. > > except (socket.herror, socket.gaierror): > newFile.write("No resolution available for %s" % (name) + "\n") > >see if that works Just a followon remark: always try to print the exception when you're not certain of what it will be or what to do with it. So I'd augument Alan's code like this: except (socket.herror, socket.gaierror) as e: newFile.write("No resolution available for %s: %s" % (name, e) + "\n") Cheers, Cameron Simpson <c...@zip.com.au> _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor