def which(program):
<EOL>if os.path.exists(program) and os.access(program, os.X_OK):<EOL><INDENT>return program<EOL><DEDENT>for path in os.environ['<STR_LIT>'].split(os.pathsep):<EOL><INDENT>path = path.strip('<STR_LIT:">')<EOL>for ext in os.environ.get('<STR_LIT>', '<STR_LIT>').split(os.pathsep):<EOL><INDENT>progpath = os.path.join(path, program + ext)<EOL>if os.path.exists(progpath) and os.access(progpath, os.X_OK):<EOL><INDENT>return progpath<EOL><DEDENT><DEDENT><DEDENT>return None<EOL>
look for "program" in PATH (respecting PATHEXT), and return the path to
        it, or None if it was not found