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


Groups > comp.lang.python > #98852

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

From eryksun <eryksun@gmail.com>
Newsgroups comp.lang.python
Subject Re: What meaning is of '#!python'?
Date 2015-11-14 23:57 -0600
Message-ID <mailman.349.1447567116.16136.python-list@python.org> (permalink)
References <ed2472ca-7efb-4676-b49e-356260dd533c@googlegroups.com> <CAPTjJmoNjpFKUgfOiejtLTjLK+yqx-MAtdGzEj4QNxcuxq4T4Q@mail.gmail.com> <CAKJDb-OtX5giW9KRSTo5F1GDp=uLHsK3qaT0p=k5yrxj7met4g@mail.gmail.com>

Show all headers | View raw


On Sat, Nov 14, 2015 at 8:26 PM, Zachary Ware
<zachary.ware+pylist@gmail.com> 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

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