From: Alan K. <jyt...@xh...> - 2007-10-02 14:58:35
|
[Greg] >>>>> try: >>... x = socket.gethostbyname("por-wq-moore") >>... print 'host ip addr: ', x >>... except gaierror, ge: >>... print 'something exceptional happened' >>... print ge >> >>And got an unexpected: >> >>Traceback (innermost last): >> File "<console>", line 2, in ? >>NameError: gaierror [Pekka] > You probably should say "from socket import gaierror" before > your try/except. Or, more simply, properly scope the exception as socket.gaierror, like so try: x = socket.gethostbyname("por-wq-moore") print 'host ip addr: ', x except socket.gaierror, ge: print 'something exceptional happened' print ge Regards, Alan. |