Something like this can be used for 'which':
def which(name):
result = []
exts = filter(None, os.environ.get('PATHEXT', '').split(os.pathsep))
path = os.environ.get('PATH', None)
if path is None:
return []
for p in os.environ.get('PATH', '').split(os.pathsep):
p = os.path.join(p, name)
print(p)
if os.access(p, os.X_OK):
result.append(p)
for e in exts:
pext = p + e
if os.access(pext, os.X_OK):
result.append(pext)
return result
Something like this can be used for 'which': get('PATHEXT' , '').split( os.pathsep) ) get('PATH' , None) get('PATH' , '').split( os.pathsep) : append( pext)
def which(name):
result = []
exts = filter(None, os.environ.
path = os.environ.
if path is None:
return []
for p in os.environ.
p = os.path.join(p, name)
print(p)
if os.access(p, os.X_OK):
result.append(p)
for e in exts:
pext = p + e
if os.access(pext, os.X_OK):
result.
return result