How to handle errors?

Joaquin Alzola Joaquin.Alzola at lebara.com
Thu Oct 20 16:02:45 EDT 2016


> [root at bart /]# ./dataman.py
>Enter a domain name: aslfhafja
>Your domain is  aslfhafja
>Traceback (most recent call last):
 > File "./dataman.py", line 7, in <module>
 >   print socket.gethostbyname(str)
>socket.gaierror: [Errno -2] Name or service not known
>[root at bart /]#

>I would like to be able to handle that error a bit better.  Any ideas?

Go with the "try  ... except ..."

https://docs.python.org/3/tutorial/errors.html
This email is confidential and may be subject to privilege. If you are not the intended recipient, please do not copy or disclose its content but contact the sender immediately upon receipt.



More information about the Python-list mailing list