Is "#!/usr/bin/env python" the better shebang line ?

Benjamin Kaplan benjamin.kaplan at case.edu
Sun Sep 6 16:22:31 CEST 2009


On Sun, Sep 6, 2009 at 10:01 AM, Timothy Madden<terminatorul at gmail.com> wrote:
> Hello
>
> Sorry if this has been discussed before, my search did not find it.
> My questions is if I should use
>  #!/usr/bin/env python
> as the shebang line in a portable and open python script and if it does help
> with portability and usage.
>
> First, can one not find /usr/bin/python in any standard system, at least as
> much as /usr/bin/env can be found ?
>
Not necessarily. The system python (if it exists) is usually in
/usr/bin but what if there is no system-installed Python or the user
would prefer to use a version they compiled themselves and is
therefore in /usr/local/bin? Or what if the system decides /usr/bin is
just for the default system tools and everything else should be
installed in /opt/? env will always be in the same place, but Python
may not be so using env makes it more portable.


> Then, supposing /usr/bin/env is better than /usr/bin/python and I use it, is
> it not the case that many editors and code analysing programs, that want to
> know the script language for syntax highlighting, code completion, tags and
> source code browsing, etc, will loose their functionality because of this
> shebang line ? Is this not a good general reason to use the old one ?
>
> Now I know env is POSIX standard utility, and python is not, and maybe that
> could be reason enough, but are there any other issues involved with using
> /usr/bin/env ?
>
> Thank you
> Timothy Madden
> --
> http://mail.python.org/mailman/listinfo/python-list
>



More information about the Python-list mailing list