Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #98851

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

From Rob Hills <rhills@medimorphosis.com.au>
Newsgroups comp.lang.python
Subject Re: What meaning is of '#!python'?
Date 2015-11-15 11:10 +0800
Message-ID <mailman.348.1447557067.16136.python-list@python.org> (permalink)
References <ed2472ca-7efb-4676-b49e-356260dd533c@googlegroups.com> <mailman.340.1447552722.16136.python-list@python.org> <3aa2f352-ea19-4252-9a09-c884887cf810@googlegroups.com> <CAPTjJmqs7yEeana50mH0PxayiUwsSBXeye2_gKcEFbUkbVQeWQ@mail.gmail.com>

Show all headers | View raw


On 15/11/15 10:18, Chris Angelico wrote:
> On Sun, Nov 15, 2015 at 1:13 PM, fl <rxjwg98@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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

What meaning is of '#!python'? fl <rxjwg98@gmail.com> - 2015-11-14 17:54 -0800
  Re: What meaning is of '#!python'? Chris Angelico <rosuav@gmail.com> - 2015-11-15 12:58 +1100
    Re: What meaning is of '#!python'? fl <rxjwg98@gmail.com> - 2015-11-14 18:13 -0800
      Re: What meaning is of '#!python'? Chris Angelico <rosuav@gmail.com> - 2015-11-15 13:18 +1100
      Re: What meaning is of '#!python'? Rob Hills <rhills@medimorphosis.com.au> - 2015-11-15 11:10 +0800
  Re: What meaning is of '#!python'? Zachary Ware <zachary.ware+pylist@gmail.com> - 2015-11-14 20:26 -0600
  Re: What meaning is of '#!python'? Michael Torrie <torriem@gmail.com> - 2015-11-14 19:28 -0700
  Re: What meaning is of '#!python'? eryksun <eryksun@gmail.com> - 2015-11-14 23:57 -0600
  Re: What meaning is of '#!python'? <paul.hermeneutic@gmail.com> - 2015-11-15 21:54 -0700

csiph-web