Python Practice › OS Module Programs › Program 26
Folders searched for programs
Write a Python program to list the folders searched for executables with os.get_exec_path().
Output
list True True
Approach
- It returns the PATH folders as a list.
Solution
import os paths = os.get_exec_path()print(type(paths).__name__, len(paths) > 0)print(any(os.path.isdir(p) for p in paths))Output
list True True
Note
The real list contains folders from your computer (often with your user name), so the example only checks its shape.
Learn the concept
New to this topic? Read the lesson, then come back.