2.4. File references should work on any computer!¶
“Absolute” filepaths are absolutely bad and will result in automatic point deductions in this class when spotted.
If any of the code loads a file by loading
C:\Users\DonBowen\Desktop\Death_is_Which_Way\build\input\got1.txt, then that code will not work on your computer, or if I move my folder within my own computer!
That long file path is called an “absolute path”. No matter where you put your code, it will look for a file with that entire path.
Instead, use relative file paths, which only tells your code where to look relative to the current folder. So, now,
..\ tells it to look “one level up”, then inside the input folder.
(Aside: You can go up two levels with
..\..\ and so on…)
If you use relative paths, your code can work on anyone’s computer. This is kind of the point!