0

In my script I can select a midifile that's in the same directory as the script by typing the name of the file: 'moonlight.mid'. I chose to organize the midifiles and move them to the folder testmidifiles. I would expect that I could use 'testmidifiles/moonlight.mid' but this gives the error 'No such file in directory'. Is there a way to make this work?

As an example: projectfolder/test.py

print(open('testfolder/test.txt'))

projectfolder/testfolder/test.txt

The reason is that testing on different systems, you have to change the path to the file every time and I'm a bit lazy :) I would love to know the trick!

  • Try https://stackoverflow.com/questions/7165749/open-file-in-a-relative-location-in-python – Demi-Lune Oct 11 '20 at 08:18
  • get the directory your script is in: https://stackoverflow.com/questions/50499/how-do-i-get-the-path-and-name-of-the-file-that-is-currently-executing (not the excepted answer, but most of the others) – Wups Oct 11 '20 at 08:26

0 Answers0