What meaning is of '#!python'?
Rob Hills
rhills at medimorphosis.com.au
Sat Nov 14 22:10:54 EST 2015
On 15/11/15 10:18, Chris Angelico wrote:
> On Sun, Nov 15, 2015 at 1:13 PM, fl <rxjwg98 at gmail.com> 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
More information about the Python-list
mailing list