Folders searched for programs

EasyOS Module Programs · 26 of 49

Write a Python program to list the folders searched for executables with os.get_exec_path().

Advertisement
Output
list True
True

Approach

  1. It returns the PATH folders as a list.

Solution

Python
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.

More os module programs

← All 49 OS Module Programs

Leave a Comment