#!/usr/bin/env python vs. #!/usr/bin/python
Erik Max Francis
max at alcyone.com
Fri May 2 14:26:50 EDT 2008
Ben Finney wrote:
> No, because it's quite common for the PATH variable to have
> '/usr/local/bin' appear *before* both of '/bin' and '/usr/bin'.
>
> If the system has a sysadmin-installed '/usr/local/bin/python'
> installed as well as the OS-installed '/usr/bin/python', then the two
> shebang options the OP raised will behave differently on such a
> system. This seems to be quite the point of the discussion.
Yes, and that's the reason the env form is preferred. If someone --
either the system administrator, or the user environment, or the person
executing the program on the fly -- has changed the PATH, they did it
for a reason. If /usr/local/bin is in the PATH before /usr/bin, then
that is a deliberate choice (whether system-wide or not) to prefer
executables in /usr/local/bin to those in /usr/bin, and that is being
done for a very conscious reason. Which is why the PATH exists in the
first place, and why invoking the script with env is preferable.
--
Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
San Jose, CA, USA && 37 18 N 121 57 W && AIM, Y!M erikmaxfrancis
More information about the Python-list
mailing list