Import files not in the current working directory
<p>Let's say the program asks the user for a file name to read and then a file to write the processed data into. </p>

<p>Is there a way to get the directory of the needed file so the program can alter the current directory to use it? Or is there another way to access that file?</p>

<p>If the user enters the complete file path with the directory, you can parse it (using sys.path) and then os.chdir() there.</p>

python directory cwd