[Python-ideas] Migration of /usr/bin/python to python3

Andrew Barnert abarnert at yahoo.com
Thu Mar 12 22:05:16 CET 2015


On Mar 12, 2015, at 1:49 PM, random832 at fastmail.us wrote:

> Though, speaking of the posix shell script exec issue, and to wrench
> things back on topic... what about allowing python scripts to start with
> the line "exec python [options...] $0", a line which will be ignored by
> the python interpreter?

I vaguely remember either perl or Tcl considering something equivalent long ago as a way of dealing with BSD4.x versions that didn't pass any arguments from the shbang line (before that became irrelevant but env became a de facto practical standard and ate up the first arg, putting us right back in the equivalent place), so it might be worth searching their archives to see what came of that. (Although given the languages we're talking about, I wouldn't be surprised if the answer was "you can already do it in one line in these six different hacky ways, so we don't need to add a special way to do it", which won't apply to Python...)

However, I'm not sure this solves the problem the thread is trying to solve. Yes, it gives you a portable way to let 3.5+ scripts pass extra arguments to the interpreter, which might be useful for other reasons (and if so, I think a new thread laying out the rationale would be handy). But the problem people were trying to solve here is that `#!/usr/bin/env python2 -m spam` isn't portable (and neither is `#!/usr/local/bin/spam` where spam is a Python script), and you can't retroactively change 2.x.


More information about the Python-ideas mailing list