Skip to content

Path

A path is a file's address on your computer: the folders you go through to reach it, ending in the file's name, like projects/python-for-altair/life_expectancy.csv.

A path can be absolute, starting from the top of the disk (/Users/ana/projects/... on a Mac, C:\Users\ana\... on Windows), or relative, starting from the folder you're working in. "life_expectancy.csv" on its own is a relative path: the file with that name, right here.

Python's pathlib turns a path into an object you can ask things of:

python
from pathlib import Path
Path("life_expectancy.csv").exists()

When Python says FileNotFoundError, the path points somewhere the file isn't. The working directory is the first thing to check.

Learn more

  • Working directory

    The working directory is the folder a program treats as "here". A file name with no folders in front of it, like life_expectancy.csv, is looked for in that folder.

All terms