#! independent of location of python binary
Harald Kirsch
kirschh at lionbioscience.com
Wed Sep 20 11:16:35 EDT 2000
In Tcl I write
#!/bin/sh
# \
exec tclsh "$0" ${1+"$@"}
and the tclsh will be found along the path.
How can I do this in python. I tried
#!/bin/sh
exec python $@ -c "`tail +3 $0`"
but this is of course suboptimal because sys.argv[0] becomes `-c'.
The next one was:
#!/bin/sh
exec python $@ -c "import sys;sys.argv[0]='$0';`tail +3 $0`"
but things start to become really messy here. In addition, it does not
preserve semantics because it forces the import of sys.
Harald Kirsch
--
----------------+------------------------------------------------------
Harald Kirsch | kirschh at lionbioscience.com | We make the tools to
LION Bioscience | +49 6221 4038 172 | reverse engineer nature.
*** Please: Never Ever Mail Me Copies Of Your Posts ***
More information about the Python-list
mailing list