Re: How to handle errors?

2016-11-09 Thread Bev in TX
On UNIX type systems, the Python installer creates multiple links to the actual Python executable. For example in Python 3.5: python - link to python3.5 python3 - link to python3.5 python3.5 - actual executable Unless your script specifically requires version 3.5, then it is better to use

Re: How to handle errors?

2016-10-22 Thread Wildman via Python-list
On Sat, 22 Oct 2016 15:01:46 +, John Gordon wrote: > In Wildman > writes: > >> > Another serious problem with using env in the hash-bang line is that you >> > cannot pass commandline options to the Python executable. > >>

Re: How to handle errors?

2016-10-22 Thread John Gordon
In Wildman writes: > > Another serious problem with using env in the hash-bang line is that you > > cannot pass commandline options to the Python executable. > Not true. I made a test script with this code: > #!/usr/bin/env

Re: How to handle errors?

2016-10-21 Thread Wildman via Python-list
On Fri, 21 Oct 2016 16:14:41 +1100, Steve D'Aprano wrote: > On Fri, 21 Oct 2016 11:03 am, Wildman wrote: > >> On Thu, 20 Oct 2016 12:48:28 -0700, SS wrote: >> >>> The following script works fine: >>> >>> #!/bin/python >> >> I meant to include this with my other post but I forgot it. >> >>

Re: How to handle errors?

2016-10-20 Thread Steve D'Aprano
On Fri, 21 Oct 2016 11:03 am, Wildman wrote: > On Thu, 20 Oct 2016 12:48:28 -0700, SS wrote: > >> The following script works fine: >> >> #!/bin/python > > I meant to include this with my other post but I forgot it. > > Using a direct path to the Python interpreter can cause problems > on some

Re: How to handle errors?

2016-10-20 Thread D'Arcy Cain
On 2016-10-20 08:03 PM, Wildman via Python-list wrote: Using a direct path to the Python interpreter can cause problems on some systems because it is not always installed to the same directory. On my Debian-based system Python is installed in /usr/bin. So your code as written will not run on

Re: How to handle errors?

2016-10-20 Thread Wildman via Python-list
On Thu, 20 Oct 2016 12:48:28 -0700, SS wrote: > The following script works fine: > > #!/bin/python I meant to include this with my other post but I forgot it. Using a direct path to the Python interpreter can cause problems on some systems because it is not always installed to the same

Re: How to handle errors?

2016-10-20 Thread Wildman via Python-list
On Thu, 20 Oct 2016 12:48:28 -0700, SS wrote: > The following script works fine: > > #!/bin/python > > import socket > > str = raw_input("Enter a domain name: "); > print "Your domain is ", str > print socket.gethostbyname(str) > > You provide it a hostname, it provides an IP. That works

Re: How to handle errors?

2016-10-20 Thread Steve D'Aprano
On Fri, 21 Oct 2016 06:48 am, SS wrote: > The following script works fine: > > #!/bin/python > > import socket > > str = raw_input("Enter a domain name: "); > print "Your domain is ", str > print socket.gethostbyname(str) > > You provide it a hostname, it provides an IP. That works fine.

RE: How to handle errors?

2016-10-20 Thread Joaquin Alzola
> [root@bart /]# ./dataman.py >Enter a domain name: aslfhafja >Your domain is aslfhafja >Traceback (most recent call last): > File "./dataman.py", line 7, in > print socket.gethostbyname(str) >socket.gaierror: [Errno -2] Name or service not known >[root@bart /]# >I would like to be able to

Re: How to handle errors?

2016-10-20 Thread John Gordon
In <8500044a-c8d1-43ad-91d9-e836d52bd...@googlegroups.com> SS writes: > I would like to be able to handle that error a bit better. Any ideas? Wrap the socket.gethostbyname() call in a try/except block. -- John Gordon A is for Amy, who fell down the

How to handle errors?

2016-10-20 Thread SS
The following script works fine: #!/bin/python import socket str = raw_input("Enter a domain name: "); print "Your domain is ", str print socket.gethostbyname(str) You provide it a hostname, it provides an IP. That works fine. But I need a way to handle errors. For example: [root@bart /]#