File Paths#
File Systems#
When you click through the folders (directories) on your computer, you’re interacting with this hierarchical system.
File Paths#
When using a Graphical User Interface (GUI), you click on directories to access subdirectories and finally find the file you’re interested in.
When using the command line, you specify a file’s path explicitly with text.
Absolute vs. Relative Paths#
There are two ways to specify the path to your file of interest allow for flexibility in programming. Using absolute paths and using relative paths.
Absolute Paths#
root specifies the ‘highest’ directory in the file structure (the start).
An absolute file path starts with a slash /
specifying the root directory.
The absolute path to A2.ipynb
would be:
/Teaching/COGS18/A2.ipynb
initial forward slash indicates root directory
Teaching
is in rootCOGS18
is in taechingfile is in COGS 18
Relative Paths#
The computer keeps track of your current working directory.
If your current working directory were Teaching
…and you wanted to access the A2.ipynb
file in COGS 18, you could use the relative path:
COGS18/A2.ipynb
Notes:
No leading slash indicating a relative path
Path is specified relative to current location