What is the difference between an absolute path and a relative path?
Quick answer
An absolute path identifies a location from a filesystem root, so its meaning does not depend on your current directory. A relative path is interpreted from a current directory or other starting location, so the same text can point somewhere different when that starting location changes. Use an absolute path when you need an unambiguous location; use a relative path when the destination should be described in relation to where you are working.
The question, the details, the next step.
A practical checklist
Name the file or folder you intend to reach.
Identify the current or starting directory used by the relevant tool.
For a relative path, combine it with that starting directory and check the result.
For an absolute path, confirm its root and folders fit the environment.
When sharing a relative path, state the folder from which to interpret it.
A few more useful answers
Can the same relative path point to different files?
Yes. Its meaning depends on the starting directory, so the same relative path text can lead to different locations from different folders.
Is an absolute path guaranteed to work on another computer?
No. It identifies a location from a root in its environment, but another computer may have a different folder layout or path conventions.
Are all paths beginning with a drive letter absolute?
Not necessarily. Python’s documentation distinguishes Windows drive-relative c:foo from drive-rooted c:\foo; check the path rules for the platform and tool you use. [S1]
Sources
References used for this guide.
- [S1] Python os.path — Common pathname manipulations docs.python.org · Checked
