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 the
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.
>
>> Not true. I made a test script with this code:
>
>> #!/usr/bin/en
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 python
> import sys
> print sys.argv
> Then I ran it:
> ~$ python
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.
>>
>> Usi
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
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 my
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
director
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 fine
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. But
> [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 h
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 stairs
gor...@panix.com
11 matches
Mail list logo