#!/usr/bin/env python vs. #!/usr/bin/python

Wojciech Walczak wojtek.gminick.walczak at gmail.com
Tue May 6 11:11:37 EDT 2008


2008/5/6, Ben Finney <bignose+hates-spam at benfinney.id.au>:
>  > >  So why not put symlink to Python over there on all machines, if
>  > >  we can put one (or env itself) there ?
> > To avoid linking all the rest of interpreters like perl, ruby, lua
>  > and dozens of others.
> The argument was being made from "thousands of scripts". Isn't "dozens
>  of symlinks" better?

I think that depending on /usr/bin/env is more farsighted and saves some future
headaches. Creating links in /usr/bin/ means, that you have to change them
whenever you update your software (e.g. any of your many interpreters ;-)).
Changing the "#!/usr/bin/python" into "#!/usr/bin/env python" means that you do
your job once, and you can sleep well. It also is more portable.

How was it in perl?
perl -p -i -e 's/#\!\/usr\/bin\/python/#\!\/usr\/bin\/env python/' *.py

Funny thing, I have just ls'ed /usr/bin/python on my system:
$ ls -l /usr/bin/python
lrwxrwxrwx 1 root root 24 2007-11-16 14:02 /usr/bin/python ->
/usr/local/bin/python2.5

:-)

-- 
Regards,
Wojtek Walczak
http://www.stud.umk.pl/~wojtekwa/



More information about the Python-list mailing list