def find_executable(executable, path=None):
if path is None:<EOL><INDENT>path = os.environ['<STR_LIT>']<EOL><DEDENT>paths = path.split(os.pathsep)<EOL>extlist = ['<STR_LIT>']<EOL>if os.name == '<STR_LIT>':<EOL><INDENT>ext = os.path.splitext(executable)<EOL>if not ext:<EOL><INDENT>executable = executable + "<STR_LIT>"<EOL><DEDENT><DEDENT>elif sys.platform == '<STR_LIT:win32>':<EOL><INDENT>pathext = os.environ['<STR_LIT>'].lower().split(os.pathsep)<EOL>ext = os.path.splitext(executable)<EOL>if ext not in pathext:<EOL><INDENT>extlist = pathext<EOL><DEDENT><DEDENT>for ext in extlist:<EOL><INDENT>execname = executable + ext<EOL>if os.path.isfile(execname):<EOL><INDENT>return execname<EOL><DEDENT>else:<EOL><INDENT>for pth in paths:<EOL><INDENT>fil = os.path.join(pth, execname)<EOL>if os.path.isfile(fil):<EOL><INDENT>return fil<EOL><DEDENT><DEDENT>break<EOL><DEDENT><DEDENT>else:<EOL><INDENT>return None<EOL><DEDENT>
Try to find 'executable' in the directories listed in 'path' (a
    string listing directories separated by 'os.pathsep'; defaults to
    os.environ['PATH']).