Where Am I

| 1 min read

Modules

os pathlib

Finding The Path Of Your Script

os module

base_dir = os.path.dirname(__file__)

pathlib

base_dir = pathlib.Path(__file__).parent

The Users Director

os module

# this can change if you change directories in the script
user_dir = os.getcwd()

pathlib module

# this can change if you change directories in the script
user_dir = pathlib.Path.cwd()