tips

Absolute and Relative Directories in Python

One of the most common tasks (for me at least) is saving or getting data from another directory from where the current python script is running. However, for many of the file I/O functions, it assumes the current directory or you need to give it an absolute directory. Using something like ../other_directory will not work. Here is one way you can get the current script directory, and then append to the string the relative paths.