path
The location of a file or folder written as the folders leading to it, such as /home/ana/notes.txt or C:\Users\ana\notes.txt.
In more detail
Windows separates folders with backslashes and starts with a drive letter; macOS and Linux use forward slashes from /. Gluing path strings together by hand breaks across systems, so use pathlib, which builds the right form with /.
Related terms
- absolute path — A path that starts from the top of the file system, such as /home/ana/notes.txt or C:\Users\ana\notes.txt, and so works from anywhere.
- relative path — A file path given from the current directory, such as site/index.html, rather than from the root of the filesystem.
- pathlib — Python's standard library module for working with file paths as objects rather than plain strings.
- directory — A folder: a named container in a filesystem that holds files and other directories.
Taught in
- What A Program Really Is — Hands-on Python: Complete Video Course & Book
- Installing Python On Windows — Hands-on Python: Complete Video Course & Book
- Installing Python On A Mac — Hands-on Python: Complete Video Course & Book
- Where Python Lives: PATH And Versions — Hands-on Python: Complete Video Course & Book
- Paths And Files The Modern Way — Hands-on Python: Complete Video Course & Book