def which(program):
if (os.path.isabs(program) and os.path.isfile(program)<EOL>and os.access(program, os.X_OK)):<EOL><INDENT>return [program]<EOL><DEDENT>candidates = []<EOL>locations = os.environ.get("<STR_LIT>").split(os.pathsep)<EOL>for location in locations:<EOL><INDENT>candidate = os.path.join(location, program)<EOL>if os.path.isfile(candidate) and os.access(candidate, os.X_OK):<EOL><INDENT>candidates.append(candidate)<EOL><DEDENT><DEDENT>return candidates<EOL>
Returns a list of paths where the program is found.