, Python :
#! /usr/bin/env python2.6
- sys.version_info, :
if (sys.version_info[0] != 2) or (sys.version_info[1]<6):
if sys.version_info[0] > 2:
print("Version 2.6+, and not 3.0+ needed.")
sys.exit(1)
else:
print "Version 2.6+, needed. Please upgrade Python."
sys.exit(1)
-, , , , script "python2.6" ; :
-
- UNIX- , .
- , Python2.7, Python 2.6.
"" Python script, "python2.6"... "python2.9", 2.6+ Python 3.0+. script , python, . script , , Python.
, Python:
def which(program):
import os
def is_exe(fpath):
return os.path.exists(fpath) and os.access(fpath, os.X_OK)
fpath, fname = os.path.split(program)
if fpath:
if is_exe(program):
return program
else:
for path in os.environ["PATH"].split(os.pathsep):
exe_file = os.path.join(path, program)
if is_exe(exe_file):
return exe_file
return None
def first_which(progs):
for prog in progs:
progloc = which(prog)
if progloc != None:
return progloc
return None
def main():
interpreter=first_which(["python2.6","python2.7","python2.8","python2.9"])
# Invoke your program using "interpreter"
# You will need to use os.popen or subprocess,
# depending on the version of Python which which
# this launcher script was invoked...
, , , -... Python , , Python ( ... ).
Python . , , Python. , .