my code scans the directories in the 'PATH' environment variable.
if sys.version_info.major<3: for p in os.environ.get('PATH','').split(':'): if p and os.path.exists(p+'/python3'): os.execvp(p+'/python3',['python3']+sys.argv)or i could just let
os.execvp
do the PATH scan.Output:lt1/forums /home/forums 14> py
Python 2.7.12 (default, Nov 19 2016, 06:48:10)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.execvp('python3',['python3'])
Python 3.5.2 (default, Sep 14 2017, 22:51:06)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> try:
... os.execvp('python4',['python4'])
... except FileNotFoundError:
... print("oops! you don't have python4")
...
oops! you don't have python4
>>> os.execvp('python',['python'])
Python 2.7.12 (default, Nov 19 2016, 06:48:10)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> try:
... os.execvp('python4',['python4'])
... except OSError:
... print("oops! you don't have python4")
...
oops! you don't have python4
>>>
lt1/forums /home/forums 16>
yes, i want to know about any security issues you see. i don't really see any. what could the user do? change the code? change the interpreter? run something else?
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.