#!/usr/bin/python or #!/usr/bin/env python?
Stephan Kuhagen
stk at mevis.de
Wed Aug 9 02:02:03 EDT 2006
> Always prefer to use env over a hardcoded path, because that hardcoded
> path will invariably be wrong. (Yes, for those about to nitpick, it's
> conceivable that env might be somewhere other than /usr/bin. However,
> that is very rare and results in a no-win situations regardless of the
> issue of where Python is installed.)
Don't yell at me for bringing in another language, but I really like the
trick, Tcl does:
> #!/bin/sh
> # The next line starts Tcl \
> exec tclsh "$0" "$@"
This works by the somewhat weird feature of Tcl, that allows comments to be
continued in the next line with "\" at the end of the comment-line. It
looks unfamiliar, but has several advantages, I think. First it's really
VERY unlikely, that there is no /bin/sh (while I found systems with
different places for env), and you can add some other features at or before
the actual call of the interpreter, i.e. finding the right or preferred
version... - This way I coded a complete software-installer, that runs
either as a Tcl/Tk-Script with GUI, or as bash-script, when no Tcl is
available. - I really would like to have something like that for python,
but I did not find a way to achieve that, yet.
Regards
Stephan
More information about the Python-list
mailing list