Re: What meaning is of '#!python'?

2015-11-15 Thread paul.hermeneutic
The installer of some applications will replace the shebang to refer to a
specific version of Python. By doing so, it avoids problems when someone
upgrades the default Python version in the PATH.
On Nov 14, 2015 11:00 PM, "eryksun"  wrote:

> On Sat, Nov 14, 2015 at 8:26 PM, Zachary Ware
>  wrote:
> >
> > "#!python" is a valid shebang for the Python Launcher for Windows.
> > It's also a not-too-terrible placeholder for a Unix shebang meaning
> > "whichever Python you want it to be".  The better choice for use with
> > both platforms would be "#!/usr/bin/env python", though.
>
> The "/usr/bin/env python" virtual command searches the directories in
> PATH, trying each file extension from PATHEXT such as "python.COM",
> "python.EXE", and so on. You can also search for other programs such
> as "pypy". Note that qualifying "python" (but not other names) as
> "python2" or "python3.5" makes the launcher use the registry instead
> of searching PATH.
>
> "#!/usr/bin/python" may be better in some cases. This defaults to the
> latest installed version of 2.x (or 3.x if no 2.x is installed) that's
> configured in the Windows registry. Or specify "python2" or "python3"
> to use the latest 2.x or 3.x. These commands can be configured to use
> a particular major[.minor[-32]] version via the environment variables
> PY_PYTHON, PY_PYTHON2, and PY_PYTHON3. Or you can configure them
> instead by setting the "python", "python2" and "python3" keys in the
> [defaults] section of the configuration file "%LOCALAPPDATA%\py.ini".
> Note that the environment variable overrides the corresponding py.ini
> key.
>
> When portability isn't a concern you can use a Windows path in the
> shebang such as "#!C:\pypy40\pypy.exe".
>
> https://docs.python.org/3/using/windows.html#shebang-lines
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What meaning is of '#!python'?

2015-11-14 Thread eryksun
On Sat, Nov 14, 2015 at 8:26 PM, Zachary Ware
 wrote:
>
> "#!python" is a valid shebang for the Python Launcher for Windows.
> It's also a not-too-terrible placeholder for a Unix shebang meaning
> "whichever Python you want it to be".  The better choice for use with
> both platforms would be "#!/usr/bin/env python", though.

The "/usr/bin/env python" virtual command searches the directories in
PATH, trying each file extension from PATHEXT such as "python.COM",
"python.EXE", and so on. You can also search for other programs such
as "pypy". Note that qualifying "python" (but not other names) as
"python2" or "python3.5" makes the launcher use the registry instead
of searching PATH.

"#!/usr/bin/python" may be better in some cases. This defaults to the
latest installed version of 2.x (or 3.x if no 2.x is installed) that's
configured in the Windows registry. Or specify "python2" or "python3"
to use the latest 2.x or 3.x. These commands can be configured to use
a particular major[.minor[-32]] version via the environment variables
PY_PYTHON, PY_PYTHON2, and PY_PYTHON3. Or you can configure them
instead by setting the "python", "python2" and "python3" keys in the
[defaults] section of the configuration file "%LOCALAPPDATA%\py.ini".
Note that the environment variable overrides the corresponding py.ini
key.

When portability isn't a concern you can use a Windows path in the
shebang such as "#!C:\pypy40\pypy.exe".

https://docs.python.org/3/using/windows.html#shebang-lines
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What meaning is of '#!python'?

2015-11-14 Thread Rob Hills
On 15/11/15 10:18, Chris Angelico wrote:
> On Sun, Nov 15, 2015 at 1:13 PM, fl  wrote:
>> Excuse me. Below is copied from the .py file:
>>
>> #!python
>> from numpy import *
>> from numpy.random import *
>>
> Then someone doesn't know how to use a shebang (or is deliberately
> abusing it), and you can ignore it. It starts with a hash, ergo it's a
> comment.
>
> ChrisA

Looks like the author of the script file has tried to create a Python
Shell script.  This link describes them in detail:

http://www.dreamsyssoft.com/python-scripting-tutorial/intro-tutorial.php

Not sure whether the example originally quoted would work, I imagine it
might on some 'nix operating systems.

The more common first line is:

#!/usr/bin/env python

If you start a script file with this line and make the file executable,
you can then run the script from the command line without having to
preface it with a reference to your Python executable.  Eg:

my-script.py


versus

python my-script.py


HTH,

-- 
Rob Hills
Waikiki, Western Australia

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What meaning is of '#!python'?

2015-11-14 Thread Zachary Ware
On Sat, Nov 14, 2015 at 7:58 PM, Chris Angelico  wrote:
> On Sun, Nov 15, 2015 at 12:54 PM, fl  wrote:
>> I see an example Python code has such a line at the file beginning:
>>
>> #!python
>>
>>
>> Is there some meaning about it?
>
> It probably didn't look exactly like that. Please, when you're asking
> questions, COPY AND PASTE rather than retyping some approximation of
> what you saw.

"#!python" is a valid shebang for the Python Launcher for Windows.
It's also a not-too-terrible placeholder for a Unix shebang meaning
"whichever Python you want it to be".  The better choice for use with
both platforms would be "#!/usr/bin/env python", though.

-- 
Zach
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What meaning is of '#!python'?

2015-11-14 Thread Michael Torrie
On 11/14/2015 06:54 PM, fl wrote:
> Hi,
> 
> I see an example Python code has such a line at the file beginning:
> 
> #!python
> 
> 
> Is there some meaning about it?

Supposed to be, yes, but the line you've pasted there wouldn't work on
any system I know of.

https://en.wikipedia.org/wiki/Shebang_%28Unix%29

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What meaning is of '#!python'?

2015-11-14 Thread Chris Angelico
On Sun, Nov 15, 2015 at 1:13 PM, fl  wrote:
> Excuse me. Below is copied from the .py file:
>
> #!python
> from numpy import *
> from numpy.random import *
>

Then someone doesn't know how to use a shebang (or is deliberately
abusing it), and you can ignore it. It starts with a hash, ergo it's a
comment.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What meaning is of '#!python'?

2015-11-14 Thread fl
On Saturday, November 14, 2015 at 8:58:57 PM UTC-5, Chris Angelico wrote:
> On Sun, Nov 15, 2015 at 12:54 PM, fl  wrote:
> > I see an example Python code has such a line at the file beginning:
> >
> > #!python
> >
> >
> > Is there some meaning about it?
> 
> It probably didn't look exactly like that. Please, when you're asking
> questions, COPY AND PASTE rather than retyping some approximation of
> what you saw.
> 
> As it happens, I can tell what you're asking about - it's called a
> shebang - but I very much doubt that it was exactly what you wrote.
> 
> ChrisA

Excuse me. Below is copied from the .py file:

#!python
from numpy import *
from numpy.random import *


def resample(weights):
  n = len(weights)
  indices = []


Thanks,
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What meaning is of '#!python'?

2015-11-14 Thread Chris Angelico
On Sun, Nov 15, 2015 at 12:54 PM, fl  wrote:
> I see an example Python code has such a line at the file beginning:
>
> #!python
>
>
> Is there some meaning about it?

It probably didn't look exactly like that. Please, when you're asking
questions, COPY AND PASTE rather than retyping some approximation of
what you saw.

As it happens, I can tell what you're asking about - it's called a
shebang - but I very much doubt that it was exactly what you wrote.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


What meaning is of '#!python'?

2015-11-14 Thread fl
Hi,

I see an example Python code has such a line at the file beginning:

#!python


Is there some meaning about it?

Thanks,
-- 
https://mail.python.org/mailman/listinfo/python-list