#!/usr/bin/python or #!/usr/bin/env python?
Erik Max Francis
max at alcyone.com
Tue Aug 8 16:24:32 EDT 2006
John Salerno wrote:
> I understand the difference, but I'm just curious if anyone has any
> strong feelings toward using one over the other? I was reading that a
> disadvantage to the more general usage (i.e. env) is that it finds the
> first python on the path, and that might not be the proper one to use. I
> don't know if that's a real issue most of the time, but it's at least
> something to consider.
>
> And is Python found in directories other than /usr/bin often enough to
> justify using the more general form?
Yes. If Python (or indeed any other well-behaving software) is
installed manually, it will _not_ be installed in /usr/bin. /usr is
where your primary OS/distribution installation goes. Additional
software goes elsewhere, such as /usr/local.
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.)
--
Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
Never contend with a man who has nothing to lose.
-- Baltasar Gracian, 1647
More information about the Python-list
mailing list