avoiding long paths to interpreter

holger krekel pyth at devel.trillke.net
Fri Jan 10 08:52:05 EST 2003


Erik Max Francis wrote:
> holger krekel wrote:
> 
> > Probably right, although one could try putting the below into
> > a file:
> > ------------------------------------------------------------
> > #!/bin/sh
> > 
> > # find a specific python version you want to use from
> > # e.g. scanning PATH contents
> > # but i am far too lazy to write shell scripts now
> > # so i shortcut :-)
> > python=/usr/bin/python
> > 
> > $python <<__HERE__
> 	...
> 
> But this is precisely what env does in the first place, so you might as
> well just left the bangpath alone.
> 
> My point was not that using the (very common, and widely recommended)
> bangpath
> 
> 	#!/usr/bin/env python
> 
> won't work, it's just that which Python interpreter it finds depends on
> the PATH (because that is precisely what env does).  If you have
> multiple intepreters installed, then you may get unpleasant surprises if
> you're relying on finding a particular one, since PATHs will vary widely
> from interactive shell to cron job to CGI script.

the Shell script is free to look for the right python version (e.g. 
python2.1 minimum, python2.2 preferred, python2.3 possible). 
You can also choose to lookup some environment variables, check
the user id and base your decision on that. 

you can't do that with 'env'.

    holger





More information about the Python-list mailing list