def is_executable(file): if not os.path.exists(file): return False st = os.stat(file) return bool(st.st_mode & (stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH))