Python and Red Hat Linux 6

Andrew Snare ajs at pigpond.com
Wed Jul 28 02:19:33 EDT 1999


>>>>> "Bill" == Bill Janssen <janssen at parc.xerox.com> writes:

  >> You have to give #! an absolute pathname for it to work.  env is
  >> (somewhat) reliably at /usr/bin and is a program used exclusively
  >> for running other programs in certain environments.  In this
  >> case, it is used because it will search your path for python
  >> rather than requiring it to be explicit.

  Bill> Of course, it only works if python is on the PATH of the
  Bill> program executing the script.  Personally, I don't find the
  Bill> /usr/bin/env hack useful.

It used to be more useful when python tended to be in /usr/local/bin
rather than /usr/bin which is now the case on most Linux boxes. The
env hack also has the disadvantage that it doesn't let you pass
through the -O option to the python interpreter (at least under
Linux). This is the case on various other flavours of unix as well,
which is why perl reparses the first line of the perl script to get
the options instead of relying on what it was given as argv.

This topic seems to come up rather regularly. As always, I strongly
suggest people read "man perlrun" and "man tclsh" to get a good
understanding of the pro's and con's of the various methods. Maybe
this is for the FAQ?

 - Andrew thought-it-was-already-in-there Snare
-- 
#!/usr/bin/env python
print(lambda s:s+"("+`s`+")")\
('#!/usr/bin/env python\012print(lambda s:s+"("+`s`+")")\\\012')
print(lambda x:x%`x`)('print(lambda x:x%%`x`)(%s)')




More information about the Python-list mailing list