[Tutor] Exception Handling
Alan Gauld
alan.gauld at btinternet.com
Sat Oct 3 01:51:37 CEST 2015
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
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
More information about the Tutor
mailing list