* string.py: added rindex(), rfind(); changed index() to interpret

negative start indices starting from the right.
* ftplib.py: debug() -> set_debuglevel(); change demo to use __init__().
* os.py: added execl, execlp, and execvp.
* lambda.py: removed (now that we have built-in map, reduce, bagof, lambda)
* test_b{1,2}.py, testall.out: added tests for bagof, lambda, map, reduce
* commands.py: use os, not posix
* test_grammar.py: make it easy to disable non-portable int overflow tests
* dis.py: don't abuse range()
This commit is contained in:
Guido van Rossum 1993-11-08 15:05:21 +00:00
parent db65a6ce55
commit e65cce5eec
10 changed files with 161 additions and 20 deletions

View file

@ -38,3 +38,33 @@ except ImportError:
import macpath
path = macpath
del macpath
def execl(file, *args):
execv(file, args)
def execle(file, *args):
env = args[-1]
execve(file, args[:-1], env)
def execlp(file, *args):
execvp(file, args)
def execvp(file, args):
if '/' in file:
execv(file, args)
return
ENOENT = 2
if environ.has_key('PATH'):
import string
PATH = string.splitfields(environ['PATH'], ':')
else:
PATH = ['', '/bin', '/usr/bin']
exc, arg = (ENOENT, 'No such file or directory')
for dir in PATH:
fullname = path.join(dir, file)
try:
execv(fullname, args)
except error, (errno, msg):
if errno != ENOENT:
exc, arg = error, (errno, msg)
raise exc, arg