def find_executable(executable, path=None):
    '''Try to find 'executable' in the directories listed in 'path' (a
    string listing directories separated by 'os.pathsep'; defaults to
    os.environ['PATH']).'''
    if path is None:
        path = os.environ['PATH']
    paths = path.split(os.pathsep)
    extlist = ['']
    if os.name == 'os2':
        ext = os.path.splitext(executable)
        # executable files on OS/2 can have an arbitrary extension, but
        # .exe is automatically appended if no dot is present in the name
        if not ext:
            executable = executable + ".exe"
    elif sys.platform == 'win32':
        pathext = os.environ['PATHEXT'].lower().split(os.pathsep)
        ext = os.path.splitext(executable)
        if ext not in pathext:
            extlist = pathext
    for ext in extlist:
        execname = executable + ext
        if os.path.isfile(execname):
            return execname
        else:
            for pth in paths:
                fil = os.path.join(pth, execname)
                if os.path.isfile(fil):
                    return fil
            break
    else:
        return None
def find_executable(executable, path=None):
    '''Try to find 'executable' in the directories listed in 'path' (a
    string listing directories separated by 'os.pathsep'; defaults to
    os.environ['PATH']).'''
    if path is None:
        path = os.environ['PATH']
    paths = path.split(os.pathsep)
    extlist = ['']
    if os.name == 'os2':
        ext = os.path.splitext(executable)
        # executable files on OS/2 can have an arbitrary extension, but
        # .exe is automatically appended if no dot is present in the name
        if not ext:
            executable = executable + ".exe"
    elif sys.platform == 'win32':
        pathext = os.environ['PATHEXT'].lower().split(os.pathsep)
        ext = os.path.splitext(executable)
        if ext not in pathext:
            extlist = pathext
    for ext in extlist:
        execname = executable + ext
        if os.path.isfile(execname):
            return execname
        else:
            for pth in paths:
                fil = os.path.join(pth, execname)
                if os.path.isfile(fil):
                    return fil
            break
    else:
        return None
def find_executable ( executable , path = None ) : if path is None : path = os . environ [ 'PATH' ] paths = path . split ( os . pathsep ) extlist = [ '' ] if os . name == 'os2' : ext = os . path . splitext ( executable ) # executable files on OS/2 can have an arbitrary extension, but # .exe is automatically appended if no dot is present in the name if not ext : executable = executable + ".exe" elif sys . platform == 'win32' : pathext = os . environ [ 'PATHEXT' ] . lower ( ) . split ( os . pathsep ) ext = os . path . splitext ( executable ) if ext not in pathext : extlist = pathext for ext in extlist : execname = executable + ext if os . path . isfile ( execname ) : return execname else : for pth in paths : fil = os . path . join ( pth , execname ) if os . path . isfile ( fil ) : return fil break else : return None
Try to find 'executable' in the directories listed in 'path' (a
    string listing directories separated by 'os.pathsep'; defaults to
    os.environ['PATH']).
Try to find executable in the directories listed in path ( a string listing directories separated by os . pathsep ; defaults to os . environ [ PATH ] ) .